Bug 57744 - [PATCH] getMessageDate returns null when message submission chunk "id" contains hyphen
Summary: [PATCH] getMessageDate returns null when message submission chunk "id" contai...
Alias: None
Product: POI
Classification: Unclassified
Component: HSMF (show other bugs)
Version: 3.10-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Keywords: PatchAvailable
Depends on:
Reported: 2015-03-23 16:42 UTC by Adrian Conlon
Modified: 2015-07-03 11:06 UTC (History)
0 users

Proposed patch (8.18 KB, patch)
2015-03-23 16:45 UTC, Adrian Conlon
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Conlon 2015-03-23 16:42:12 UTC
The current date parser within MessageSubmissionChunk.java sees the id as containing:

This is almost correct, but the id normally seems to be a hostname of a what appears to be a mail relay.  Hostnames can contain hyphens which seems to be confusing the code that extracts the date/time to be parsed.
Comment 1 Adrian Conlon 2015-03-23 16:45:52 UTC
Created attachment 32594 [details]
Proposed patch

Reimplement part of MessageSubmissionChunk.java, readValue to get the date bit of the submission string in a different way.

Basically, works backwards from the end of the string to find delimiting hyphens.

Two test cases added: One with a hyphen in the id part of the submission chunk; the other without.
Comment 2 Dominik Stadler 2015-07-03 11:06:54 UTC
Submitted via r1688998

Note that I reworked it a bit to avoid unnecessary creation of empty String and to avoid creating multiple intermediate strings when lastIndexOf() has a way to start looking at some index already.

Also avoided a border-case where only one hyphen in the string would break substring()