mirror of
https://github.com/chatmail/core.git
synced 2026-04-18 22:16:30 +03:00
feat: do not include provider hostname in Message-ID
It is leaked by anonymous mailing lists, making it possible to tell which provider the sender is using. Use `localhost` as the hostname instead.
This commit is contained in:
12
src/tools.rs
12
src/tools.rs
@@ -289,12 +289,8 @@ pub(crate) fn validate_id(s: &str) -> bool {
|
||||
/// - this function is called for all outgoing messages.
|
||||
/// - the message ID should be globally unique
|
||||
/// - do not add a counter or any private data as this leaks information unnecessarily
|
||||
pub(crate) fn create_outgoing_rfc724_mid(from_addr: &str) -> String {
|
||||
let hostname = from_addr
|
||||
.find('@')
|
||||
.and_then(|k| from_addr.get(k..))
|
||||
.unwrap_or("@nohost");
|
||||
format!("Mr.{}.{}{}", create_id(), create_id(), hostname)
|
||||
pub(crate) fn create_outgoing_rfc724_mid() -> String {
|
||||
format!("Mr.{}.{}@localhost", create_id(), create_id())
|
||||
}
|
||||
|
||||
/// Extract the group id (grpid) from a message id (mid)
|
||||
@@ -1039,9 +1035,9 @@ DKIM Results: Passed=true, Works=true, Allow_Keychange=true";
|
||||
|
||||
#[test]
|
||||
fn test_create_outgoing_rfc724_mid() {
|
||||
let mid = create_outgoing_rfc724_mid("foo@bar.de");
|
||||
let mid = create_outgoing_rfc724_mid();
|
||||
assert!(mid.starts_with("Mr."));
|
||||
assert!(mid.ends_with("bar.de"));
|
||||
assert!(mid.ends_with("@localhost"));
|
||||
assert!(extract_grpid_from_rfc724_mid(mid.as_str()).is_none());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user