Skip to content

Commit

Permalink
Bug 69315: HSMF: At least continue processing properties after multiv…
Browse files Browse the repository at this point in the history
…alued 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
  • Loading branch information
centic9 committed Jan 11, 2025
1 parent 4f21f52 commit c1f5267
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ protected void readProperties(InputStream value) throws IOException {
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);
Expand Down Expand Up @@ -255,7 +261,7 @@ protected void readProperties(InputStream value) throws IOException {
// 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;
}
Expand Down
38 changes: 37 additions & 1 deletion poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,20 @@ Licensed to the Apache Software Foundation (ASF) under one or more

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;
Expand Down Expand Up @@ -273,4 +280,33 @@ void testCorruptFile() throws Exception {
}
}
}

@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());
}
}
}
Binary file added test-data/poifs/MailSentPropertyMultiple.msg
Binary file not shown.
Binary file modified test-data/spreadsheet/stress.xls
Binary file not shown.

0 comments on commit c1f5267

Please sign in to comment.