Skip to content

feat: protect the Date header #6877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

link2xt
Copy link
Collaborator

@link2xt link2xt commented May 28, 2025

Closes #6878
Based on #6867
This depends an a fix #6669, so we may want to postpone merging this until more users have it.

We do not try to delete resent messages
anymore. Previously resent messages
were distinguised by having duplicate Message-ID,
but future Date, but now we need to download
the message before we even see the Date.
We now move the message to the destination folder
but do not fetch it.

It may not be a good idea to delete
the duplicate in multi-device setups anyway,
because the device which has a message
may delete the duplicate of a message
the other device missed.

To avoid triggering IMAP move loop
described in the comments
we now only move the messages
from INBOX and Spam folders.

@link2xt
Copy link
Collaborator Author

link2xt commented May 28, 2025

Legacy Python test tests/test_1_online.py::test_resend_message got broken by this.
Resent message is not recognized as duplicate anymore because outer timestamp of just received message is compared to the timestamp of the fetched message:

core/src/imap.rs

Lines 603 to 610 in adcc8a9

let ts_sent = headers
.get_header_value(HeaderDef::Date)
.and_then(|v| mailparse::dateparse(&v).ok())
.unwrap_or_default();
let is_dup = is_dup_msg(is_chat_msg, ts_sent, ts_sent_old);
if is_dup {
info!(context, "Deleting duplicate message {message_id}.");
}

@link2xt link2xt force-pushed the link2xt/protect-date-header branch 4 times, most recently from caf6eff to 29d1d87 Compare May 28, 2025 07:51
@link2xt
Copy link
Collaborator Author

link2xt commented May 28, 2025

This has now broken the test added in c14f45a

@link2xt link2xt marked this pull request as draft May 28, 2025 09:37
@link2xt link2xt self-assigned this May 28, 2025
@link2xt link2xt force-pushed the link2xt/protect-date-header branch from 29d1d87 to e533c2c Compare May 28, 2025 09:51
@link2xt link2xt changed the base branch from main to link2xt/scan-folders-lock May 28, 2025 11:46
@link2xt link2xt force-pushed the link2xt/protect-date-header branch from e533c2c to 5663fff Compare May 28, 2025 11:48
@link2xt link2xt marked this pull request as ready for review May 28, 2025 11:49
@link2xt link2xt force-pushed the link2xt/protect-date-header branch 5 times, most recently from 68a4d43 to 154272e Compare May 28, 2025 15:46
@link2xt link2xt force-pushed the link2xt/scan-folders-lock branch from 7a65541 to 89df953 Compare May 28, 2025 15:46
Base automatically changed from link2xt/scan-folders-lock to main May 28, 2025 16:05
We do not try to delete resent messages
anymore. Previously resent messages
were distinguised by having duplicate Message-ID,
but future Date, but now we need to download
the message before we even see the Date.
We now move the message to the destination folder
but do not fetch it.

It may not be a good idea to delete
the duplicate in multi-device setups anyway,
because the device which has a message
may delete the duplicate of a message
the other device missed.

To avoid triggering IMAP move loop
described in the comments
we now only move the messages
from INBOX and Spam folders.
@link2xt link2xt force-pushed the link2xt/protect-date-header branch from 154272e to 10f3e09 Compare May 30, 2025 11:17
@link2xt link2xt marked this pull request as draft May 30, 2025 19:17
@link2xt
Copy link
Collaborator Author

link2xt commented May 30, 2025

We will have to use something less suspicious than unix epoch, GMX is unhappy:
#6878 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Protect the Date header
1 participant