Skip to content

Conversation

@iequidoo
Copy link
Collaborator

@iequidoo iequidoo commented Nov 1, 2025

This implements the most important parts of https://www.rfc-editor.org/rfc/rfc9788.html. Need to recheck if anything else needs implementation.

Close #7130

@iequidoo iequidoo force-pushed the iequidoo/use-em-dash-after-subject branch from 51b2395 to 9bc2aee Compare November 1, 2025 17:00
Base automatically changed from iequidoo/use-em-dash-after-subject to main November 1, 2025 17:06
@iequidoo iequidoo force-pushed the iequidoo/header-protection branch from 4264ed2 to 23c0d0a Compare November 1, 2025 17:11
@iequidoo iequidoo marked this pull request as draft November 1, 2025 17:24
@iequidoo iequidoo force-pushed the iequidoo/header-protection branch 2 times, most recently from c5ff81e to ff46db6 Compare November 1, 2025 17:59
@iequidoo iequidoo marked this pull request as ready for review November 1, 2025 19:57
@iequidoo iequidoo force-pushed the iequidoo/header-protection branch 3 times, most recently from a187251 to 12621ac Compare November 3, 2025 23:07
@iequidoo iequidoo force-pushed the iequidoo/header-protection branch from 12621ac to be769cd Compare November 3, 2025 23:58
@link2xt

This comment was marked as resolved.

@iequidoo iequidoo marked this pull request as draft November 12, 2025 08:13
@iequidoo iequidoo force-pushed the iequidoo/header-protection branch 2 times, most recently from 4b44365 to b083abb Compare November 12, 2025 20:08
@iequidoo iequidoo marked this pull request as ready for review November 12, 2025 20:09
@iequidoo iequidoo requested review from Hocuri and link2xt November 12, 2025 20:13
@iequidoo iequidoo force-pushed the iequidoo/header-protection branch 2 times, most recently from 125d413 to 3398068 Compare November 13, 2025 00:12
Copy link
Collaborator

@link2xt link2xt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code overall looks good, but I'd really prefer not to have conditional compilation just for a single test.

src/context.rs Outdated
pub(crate) connectivities: parking_lot::Mutex<Vec<ConnectivityStore>>,

#[cfg(test)]
#[allow(clippy::type_complexity)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[allow(clippy::type_complexity)]
#[expect(clippy::type_complexity)]

src/context.rs Outdated
/// see [`Context::get_connectivity()`].
pub(crate) connectivities: parking_lot::Mutex<Vec<ConnectivityStore>>,

#[cfg(test)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer not to have conditional compilation for tests. Since this is only enabled in tests, the test essentially does not test the same code as the code that is running in the apps. This can be done for one or two tests, but if we took this approach in all tests then all the code would be full of ad-hoc hooks introduced just for tests. See the comment in the test as well.

// once new core versions are sufficiently deployed.
let anonymous_recipients = false;

#[cfg(test)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having an utility function behind #[cfg(test)] is fine, but this is changing the tested function. Now we have no Rust tests that run unmodified code.

);
msg.set_subject("Dinner plans".to_string());
let chat_id = alice.create_chat(bob).await.id;
*alice.pre_encrypt_mime_cb.lock() = Some(|mut mime| {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is the only test using this hook. And to make sure it tests what it is expected to test, I cannot look at the message, but need to verify that the logic producing legacy display element behind #[cfg(test)] is correct. Just loading a binary from test-data would be fine and not require maintaining the code to construct a message with a legacy display element that we don't actually want to be able to construct.

In a way, this tests is not a mimeparser test, but a test of interoperability between the conditionally compiled mimefactory code and mimeparser.

}
}

#[cfg(test)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For other reviewers: this is apparently removed because the whole test_utils is conditionally compiled.

@iequidoo iequidoo force-pushed the iequidoo/header-protection branch 2 times, most recently from 4396d16 to c50c2a6 Compare November 14, 2025 06:50
@iequidoo
Copy link
Collaborator Author

Replaced conditional compilation with Config::TestHooks. I think it can be useful, and particularly the introduced hook because it's not the first time when we need to modify the encrypted payload and every time it's complicated (one need to take an older version or Thunderbird, etc.). Also this way the test looks simpler, one doesn't need to decrypt a message in test-data to see what is tested

@iequidoo iequidoo force-pushed the iequidoo/header-protection branch 2 times, most recently from d6e58b3 to c042288 Compare November 14, 2025 07:01
@iequidoo iequidoo requested a review from link2xt November 14, 2025 07:08
…7130)

This is a part of implementation of https://www.rfc-editor.org/rfc/rfc9788 "Header Protection for
Cryptographically Protected Email".
Omit Legacy Display Elements from "text/plain" and "text/html" (implement 4.5.3.{2,3} of
https://www.rfc-editor.org/rfc/rfc9788 "Header Protection for Cryptographically Protected Email").
…defined in RFC 9788) (#7130)

And enable it by default as the standard Header Protection is backward-compatible.

Also this tests extra IMF header removal when a message has standard Header Protection since now we
can send such messages.
@iequidoo iequidoo force-pushed the iequidoo/header-protection branch from c042288 to c9a7237 Compare November 14, 2025 22:42
@iequidoo iequidoo merged commit 1dbcd7f into main Nov 14, 2025
18 checks passed
@iequidoo iequidoo deleted the iequidoo/header-protection branch November 14, 2025 22:45
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.

Implement standard Header Protection

3 participants