aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2025-01-11 09:23:29 +0000
committerDominik Stadler <centic@apache.org>2025-01-11 09:23:29 +0000
commitc1f52674fd3f111b2514c41ce64d5226bb8a48ef (patch)
tree6dc8cc96c7c738656741be7790379911c8caab3c
parent4f21f5280a8cefd0e04440498dc813a850f6669f (diff)
downloadpoi-c1f52674fd3f111b2514c41ce64d5226bb8a48ef.tar.gz
poi-c1f52674fd3f111b2514c41ce64d5226bb8a48ef.zip
Bug 69315: HSMF: At least continue processing properties after multivalued properties
Currently processing stops at multivalued properties. This at least continues processing, so other properties are processed properly. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1923051 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java8
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java38
-rw-r--r--test-data/poifs/MailSentPropertyMultiple.msgbin0 -> 22528 bytes
-rw-r--r--test-data/spreadsheet/stress.xlsbin70656 -> 70656 bytes
4 files changed, 44 insertions, 2 deletions
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
index 91692e3897..7b037f3e5b 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
@@ -209,6 +209,12 @@ public abstract class PropertiesChunk extends Chunk {
int id = LittleEndian.readUShort(value);
long flags = LittleEndian.readUInt(value);
+ boolean multivalued = false;
+ if ((typeID & Types.MULTIVALUED_FLAG) != 0) {
+ typeID -= Types.MULTIVALUED_FLAG;
+ multivalued = true;
+ }
+
// Turn the Type and ID into helper objects
MAPIType type = Types.getById(typeID);
MAPIProperty prop = MAPIProperty.get(id);
@@ -255,7 +261,7 @@ public abstract class PropertiesChunk extends Chunk {
// to another chunk which holds the data itself
boolean isPointer = false;
int length = type.getLength();
- if (type.isPointer()) {
+ if (type.isPointer() || multivalued) {
isPointer = true;
length = 8;
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java b/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java
index 83f59bd789..49dea29aff 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java
@@ -19,13 +19,20 @@ package org.apache.poi.hsmf;
import static org.apache.poi.POITestCase.assertContains;
import static org.apache.poi.POITestCase.assertStartsWith;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hsmf.datatypes.AttachmentChunks;
+import org.apache.poi.hsmf.datatypes.Chunks;
import org.apache.poi.hsmf.datatypes.DirectoryChunk;
+import org.apache.poi.hsmf.datatypes.MAPIProperty;
import org.apache.poi.hsmf.exceptions.ChunkNotFoundException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
@@ -273,4 +280,33 @@ public final class TestBasics {
}
}
}
+
+ @Test
+ void testBug69315() throws Exception {
+ POIDataSamples testData = POIDataSamples.getPOIFSInstance();
+ try (MAPIMessage mapi = new MAPIMessage(testData.openResourceAsStream("MailSentPropertyMultiple.msg"))) {
+ assertNotNull(mapi.getAttachmentFiles());
+ assertNotNull(mapi.getDisplayBCC());
+ assertNotNull(mapi.getMessageDate());
+
+ Chunks chunks = mapi.getMainChunks();
+ assertNotNull(chunks);
+ assertNotNull(chunks.getRawProperties());
+ assertNotNull(chunks.getRawProperties().get(MAPIProperty.CLIENT_SUBMIT_TIME));
+
+ AttachmentChunks[] attachments = mapi.getAttachmentFiles();
+ for (AttachmentChunks attachment : attachments) {
+ DirectoryChunk chunkDirectory = attachment.getAttachmentDirectory();
+ if (chunkDirectory != null) {
+ MAPIMessage attachmentMSG = chunkDirectory.getAsEmbeddedMessage();
+ assertNotNull(attachmentMSG);
+ String body = attachmentMSG.getTextBody();
+ assertNotNull(body);
+ }
+ }
+
+ assertNull(mapi.getSummaryInformation());
+ assertNull(mapi.getDocumentSummaryInformation());
+ }
+ }
}
diff --git a/test-data/poifs/MailSentPropertyMultiple.msg b/test-data/poifs/MailSentPropertyMultiple.msg
new file mode 100644
index 0000000000..d07feb178e
--- /dev/null
+++ b/test-data/poifs/MailSentPropertyMultiple.msg
Binary files differ
diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls
index 1667a30b74..e4afaf91d6 100644
--- a/test-data/spreadsheet/stress.xls
+++ b/test-data/spreadsheet/stress.xls
Binary files differ