Bug 60550 - MAPIMessage parser couldn't get "Content-ID" field.
Summary: MAPIMessage parser couldn't get "Content-ID" field.
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSMF (show other bugs)
Version: 3.15-FINAL
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-04 02:28 UTC by maoblackberry
Modified: 2017-01-05 08:13 UTC (History)
0 users



Attachments
MSG messages with inline image attachments. (144.00 KB, application/x-ole-storage)
2017-01-04 15:41 UTC, maoblackberry
Details
Java file with newly added test case (7.02 KB, text/x-java)
2017-01-04 18:28 UTC, maoblackberry
Details
test file for newly added test case testReadContentIDField() (144.00 KB, application/x-ole-storage)
2017-01-04 18:30 UTC, maoblackberry
Details

Note You need to log in before you can comment on or make changes to this bug.
Description maoblackberry 2017-01-04 02:28:54 UTC
Is it OK to add a few lines of code in AttachmentChunks.record() method:

      // added an "else if" block to get CONTENT-ID field.
      else if(chunkId == MAPIProperty.ATTACH_CONTENT_ID.id) {
         attachContentId = (StringChunk) chunk;
      }

Thanks.
Comment 1 Javen O'Neal 2017-01-04 07:14:44 UTC
Sounds like a good idea!

Do you have a document (or does one our existing test documents [1]) have an attach content id that we could use for a unit test?

Are you willing to modify an existing unit test or write up a new unit test so we can verify the fix? See [2] or [3] for existing unit tests.

Also, what data type is attachContentId?

[1] HSMF test documents: https://svn.apache.org/viewvc/poi/trunk/test-data/hsmf/
[2] HSMF unit tests http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/ and http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/
Comment 2 maoblackberry 2017-01-04 15:41:03 UTC
Created attachment 34585 [details]
MSG messages with inline image attachments.

This attachments includes four inline images(attachments) with Content-ID field.
Comment 3 maoblackberry 2017-01-04 15:48:52 UTC
Hi Javen,
Thanks for the quick response.

1.
I already attached a file which has four inline attachments.

2.
Sure, I would like to take a look at the existing unit tests and add a few more accordingly.

Thanks again
Comment 4 maoblackberry 2017-01-04 18:25:19 UTC
(In reply to Javen O'Neal from comment #1)
> Sounds like a good idea!
> 
> Do you have a document (or does one our existing test documents [1]) have an
> attach content id that we could use for a unit test?
> 
> Are you willing to modify an existing unit test or write up a new unit test
> so we can verify the fix? See [2] or [3] for existing unit tests.
> 
> Also, what data type is attachContentId?
> 
> [1] HSMF test documents:
> https://svn.apache.org/viewvc/poi/trunk/test-data/hsmf/
> [2] HSMF unit tests
> http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/
> poi/hsmf/datatypes/ and
> http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/
> poi/hsmf/


Hi Javen,
Thanks for the response.
I think the data type of attachContentId should be:
public StringChunk attachContentId;

I already added a test case in TestFileWithAttachmentsRead.java (testReadContentIDField()) and uploaded the java file and associated test file(attachment_msg_inlineImg.msg) for you to review.

Thanks for the help.
Comment 5 maoblackberry 2017-01-04 18:28:17 UTC
Created attachment 34586 [details]
Java file with newly added test case

Added a new field:

private MAPIMessage inlineImgMsgAttachments;

it is initialized as :
this.inlineImgMsgAttachments = new MAPIMessage(samples.openResourceAsStream("attachment_msg_inlineImg.msg"));

Added a new test case:
public void testReadContentIDField()
Comment 6 maoblackberry 2017-01-04 18:30:15 UTC
Created attachment 34587 [details]
test file for newly added test case testReadContentIDField()

A MSG file with 4 inline image attachments.
Each of them has a Content-ID field.
Comment 7 Javen O'Neal 2017-01-05 08:13:29 UTC
Thanks for the patch, unit test, and email message file.
Feel free to check out our contributor guidelines [1], which has some examples of creating patches [2]. (a simple svn diff works too).

This will be available in 3.16 beta 2.

Applied to trunk in r1777428 and r1777429.

[1] https://poi.apache.org/guidelines.html#SubmittingPatches
[2] https://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java?r1=1777428&r2=1777427&pathrev=1777428&view=patch