TIKA-4798: Don't overwrite dcterms:modified with PR_LAST_MODIFICATION_TIME for MSG files - #2987
Draft
nddipiazza wants to merge 1 commit into
Draft
TIKA-4798: Don't overwrite dcterms:modified with PR_LAST_MODIFICATION_TIME for MSG files#2987nddipiazza wants to merge 1 commit into
nddipiazza wants to merge 1 commit into
Conversation
…_TIME for MSG files - Removed the code in OutlookExtractor.handleGeneralDates() that unconditionally overwrote TikaCoreProperties.MODIFIED with the raw MAPI PR_LAST_MODIFICATION_TIME property. That property records when a .msg file's underlying storage was last written to disk (e.g. when re-saved or exported by Outlook), not when the message content was actually edited, and can be months after the message was sent/received. - dcterms:modified now falls back to the message date (delivery/submit time), matching Tika 2.9.0 behavior. - The raw PR_LAST_MODIFICATION_TIME value remains available, unchanged, under mapi:last-modification-time. - Added a regression test asserting both values on test-outlook.msg, whose PR_LAST_MODIFICATION_TIME diverges from its message date by six months. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
lgtm. Do we want to fix PST while we're at it? Or separate PR? From my claude: |
Contributor
|
PST PR is here: #2988 |
Contributor
|
@nddipiazza looks ready to me. Go forth and merge when ready! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes TIKA-4798:
dcterms:modifiedfor.msg(Outlook MAPI) files changed between Tika 2.9.0 and 3.2.3.Root Cause
TIKA-4360 (#2073, merged into the 3.x line in Dec 2024) added code to
OutlookExtractor.handleGeneralDates()that unconditionally overwritesTikaCoreProperties.MODIFIED(dcterms:modified) with the raw MAPIPR_LAST_MODIFICATION_TIMEproperty whenever it is present.PR_LAST_MODIFICATION_TIMErecords when the.msgfile's underlying CFB/OLE storage was last written to disk (e.g. when Outlook re-saves or exports the item as a.msgfile) — it is not a semantic "the email content was edited" timestamp. Since an email's content is effectively immutable once sent, this property commonly reflects a later, unrelated storage-level event (archival, export, re-indexing, etc.), not a real content modification.I confirmed this against the reporter's attached sample files:
PR_LAST_MODIFICATION_TIMEforSample1.msgis2018-10-06T00:03:21Z, exactly matching the "wrong" 3.2.3 value reported in the ticket, whilemsg.getMessageDate()(delivery/submit time, used in 2.9.0) is2018-08-03T19:13:22Z, matching the "expected" 2.9.0 value.Changes
OutlookExtractor.handleGeneralDates()that overwrotedcterms:modifiedwithPR_LAST_MODIFICATION_TIME.dcterms:modifiednow falls back to the message date (delivery/submit time) again, matching 2.9.0 behavior.mapi:last-modification-time(already populated separately byhandleMessageInfo/LITERAL_TIME_PROPERTIES, added in the same TIKA-4360 change).OutlookParserTest#testOutlookParsingusing the existingtest-outlook.msgresource, whosePR_LAST_MODIFICATION_TIMEdiverges from its message date by about six months — the same kind of divergence reported in the ticket.Review Focus Areas
dcterms:modifiedreflect message date orPR_LAST_MODIFICATION_TIME? This PR takes the position that message date is the more meaningful default for email, givenPR_LAST_MODIFICATION_TIME's storage-level semantics, while still exposing the raw MAPI value separately.Critical Files
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/OutlookExtractor.javatika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/test/java/org/apache/tika/parser/microsoft/OutlookParserTest.javaTesting Instructions
Also ran the full module test suite (
mvn test) with no new failures, and manually parsed the reporter's attached sample.msgfiles to confirmdcterms:modifiednow matches the value produced by Tika 2.9.0.Review Checklist
Potential Concerns
dcterms:modifiedvalue (intentionally or not) will see it change again. Given this was an undocumented, likely unintended side effect of TIKA-4360, I believe reverting to the original, more intuitive semantics is the right call, with the raw property still available undermapi:last-modification-timefor anyone who wants it.