Bug 57744

Summary: [PATCH] getMessageDate returns null when message submission chunk "id" contains hyphen
Product: POI Reporter: Adrian Conlon <adrian.conlon>
Component: HSMFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal Keywords: PatchAvailable
Priority: P2    
Version: 3.10-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Proposed patch

Description Adrian Conlon 2015-03-23 16:42:12 UTC
The current date parser within MessageSubmissionChunk.java sees the id as containing:
  l=<id>-<time>-<number>

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()