Preserve the original message date on import of EML messages (#5559)#10251
Open
MiMoHo wants to merge 1 commit into
Open
Preserve the original message date on import of EML messages (#5559)#10251MiMoHo wants to merge 1 commit into
MiMoHo wants to merge 1 commit into
Conversation
…be#5559) The import action extracts the received date from the mbox from-line and passes it to IMAP APPEND as the message INTERNALDATE (roundcube#5559), but for EML input no date was extracted at all, so imported messages got the time of the import as their INTERNALDATE. This affects sorting by arrival date, SEARCH BEFORE/SINCE, and the list display with mail_pagesize arrival date. Fall back to the message's Date header when no date was found - i.e. for EML input, and also for mbox messages whose from-line has no recognized date. The header block is split off before parsing, so Date-like lines in the message body are ignored, and an invalid or missing Date header keeps the previous behavior (APPEND without a date-time). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
Since #5559 the import action preserves the original message date, but only for mbox input, where the received date is taken from the mbox from-line and passed to IMAP
APPENDas the message INTERNALDATE. As noted back then:For EML input (single files or inside ZIP archives) no date is extracted at all, so every imported message gets the time of the import as its INTERNALDATE. That affects sorting by arrival date,
SEARCH BEFORE/SINCE, and the message list when the arrival date is displayed — a mailbox restored from EML backups shows all messages as "received" at import time.Change
When no date was found,
rcmail_action_mail_import::save_message()now falls back to the message'sDateheader:Dateheader is the only original date an EML file carries, and it is close enough to the delivery time that INTERNALDATE is supposed to hold. Other clients (e.g. Thunderbird's ImportExportTools) do the same on EML import.null; the Date header is a strictly better fallback than the import time.Implementation notes:
rcube_mime::parse_headers()), soDate:-like lines in the message body cannot be picked up.rcube_utils::anytodatetime(); RFC 2822 dates keep their original UTC offset all the way into theAPPENDdate-time string.Dateheader keeps the previous behavior (APPENDwithout a date-time, i.e. server assigns the current time).Testing
ImportTest::test_save_message_date()covers: EML with Date header, header-only message, missing Date header with a Date-like line in the body (must be ignored), unparsable Date header, and the mbox from-line fallback.ImportTestnow also assert the date argument passed tosave_message()for both the EML and the mbox path (the mbox from-line date extraction was previously untested).APPENDcommand:Date: Fri, 23 May 2014 19:44:50 +0200→rcube_utils::anytodatetime()→rcube_imap::date_format()→"23-May-2014 19:44:50 +0200";nullpropagates to anAPPENDwithout date-time.This contribution was prepared with AI assistance (Claude); the analysis, implementation and tests were reviewed and verified by test runs as described above.
🤖 Generated with Claude Code