Author: centic
Date: Sat Jan 11 09:23:29 2025
New Revision: 1923051
URL: http://svn.apache.org/viewvc?rev=1923051&view=rev
Log:
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.
Added:
poi/trunk/test-data/poifs/MailSentPropertyMultiple.msg
Modified:
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java
poi/trunk/test-data/spreadsheet/stress.xls
Modified:
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java?rev=1923051&r1=1923050&r2=1923051&view=diff
==============================================================================
---
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
(original)
+++
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
Sat Jan 11 09:23:29 2025
@@ -209,6 +209,12 @@ public abstract class PropertiesChunk ex
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 ex
// 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;
}
Modified:
poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java?rev=1923051&r1=1923050&r2=1923051&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java
(original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java
Sat Jan 11 09:23:29 2025
@@ -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());
+ }
+ }
}
Added: poi/trunk/test-data/poifs/MailSentPropertyMultiple.msg
URL:
http://svn.apache.org/viewvc/poi/trunk/test-data/poifs/MailSentPropertyMultiple.msg?rev=1923051&view=auto
==============================================================================
Binary files poi/trunk/test-data/poifs/MailSentPropertyMultiple.msg (added) and
poi/trunk/test-data/poifs/MailSentPropertyMultiple.msg Sat Jan 11 09:23:29 2025
differ
Modified: poi/trunk/test-data/spreadsheet/stress.xls
URL:
http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/stress.xls?rev=1923051&r1=1923050&r2=1923051&view=diff
==============================================================================
Binary files - no diff available.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]