Adam Rauch created TIKA-4959:
--------------------------------
Summary: OutlookExtractor never uses the Date: transport header,
because header keys are stored without the colon
Key: TIKA-4959
URL: https://issues.apache.org/jira/browse/TIKA-4959
Project: Tika
Issue Type: Bug
Components: parser
Affects Versions: 4.1.0, 3.3.2, 2.9.2
Environment: Eclipse Adoptium OpenJDK 25.0.4.1+1-LTS on Windows 11
Reporter: Adam Rauch
Discovered while upgrading to 4.1.0 with assistance from Claude Code. This
report is Claude-generated, but reviewed and edited by a human.
When an Outlook {{.msg}} file has no message date property (no submission
chunk, and none of {{{}PR_CLIENT_SUBMIT_TIME{}}}, {{PR_CREATION_TIME}} or
{{{}PR_LAST_MODIFICATION_TIME{}}}), {{OutlookExtractor.handleGeneralDates()}}
is meant to fall back to the {{Date:}} line in the transport headers. That
fallback can never run, so such messages get no
{{{}dcterms:created{}}}/{{{}dcterms:modified{}}}, even when the headers contain
a valid date.
{{normalizeHeaders()}} stores each header under its bare name.
{{HEADER_KEY_PAT}} excludes {{:}} from the key, so the {{Date:}} line is stored
under the key {{{}Date{}}}. {{handleGeneralDates()}} then tests:
{code:java}
if (headerKey.toLowerCase(Locale.ROOT).startsWith("date:")) {
String date = headerKey.substring(headerKey.indexOf(':') + 1).trim();
{code}
No key can contain a colon, so the condition is always false and
{{MailDateParser.parseDateLenient()}} is never reached. The value extraction is
also wrong: it
reads the date from the key, not from the header's value.
Steps to reproduce
Take a {{.msg}} with {{PR_TRANSPORT_MESSAGE_HEADERS}} containing a {{Date:}}
line, for example {{{}Date: Thu, 5 Apr 2007 09:26:06 -0700{}}}.
Remove the top-level {{{}0x0039{}}}, {{0x3007}} and {{0x3008}} entries from
{{{}__properties_version1.0{}}}. With POI, {{MAPIMessage.getMessageDate()}} now
returns null, and {{getHeaders()}} still contains the {{Date:}} line.
Parse it with {{{}AutoDetectParser{}}}.
Expected: {{dcterms:created}} and {{dcterms:modified}} are
2007-04-05T16:26:06Z, from the header.
Actual: both are absent.
Suggested fix:
{code:java}
if (headerKey.equalsIgnoreCase("date") && header.getValue().length > 0) {
String date = header.getValue()[0];
{code}
Related: TIKA-4798 (PR #2987) changes the same method.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)