mirror of
https://github.com/chatmail/core.git
synced 2026-05-20 07:16:31 +03:00
feat: hide the To header in encrypted messages
This commit is contained in:
@@ -790,15 +790,6 @@ async fn test_self_talk() -> Result<()> {
|
|||||||
assert!(msg.get_showpadlock());
|
assert!(msg.get_showpadlock());
|
||||||
|
|
||||||
let sent_msg = t.pop_sent_msg().await;
|
let sent_msg = t.pop_sent_msg().await;
|
||||||
let payload = sent_msg.payload();
|
|
||||||
// Make sure the `To` field contains the address and not
|
|
||||||
// "undisclosed recipients".
|
|
||||||
// Otherwise Delta Chat core <1.153.0 assigns the message
|
|
||||||
// to the trash chat.
|
|
||||||
assert_eq!(
|
|
||||||
payload.match_indices("To: <alice@example.org>\r\n").count(),
|
|
||||||
1
|
|
||||||
);
|
|
||||||
|
|
||||||
let t2 = TestContext::new_alice().await;
|
let t2 = TestContext::new_alice().await;
|
||||||
t2.recv_msg(&sent_msg).await;
|
t2.recv_msg(&sent_msg).await;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use anyhow::{bail, Context as _, Result};
|
|||||||
use base64::Engine as _;
|
use base64::Engine as _;
|
||||||
use chrono::TimeZone;
|
use chrono::TimeZone;
|
||||||
use deltachat_contact_tools::sanitize_bidi_characters;
|
use deltachat_contact_tools::sanitize_bidi_characters;
|
||||||
use mail_builder::headers::address::{Address, EmailAddress};
|
use mail_builder::headers::address::Address;
|
||||||
use mail_builder::headers::HeaderType;
|
use mail_builder::headers::HeaderType;
|
||||||
use mail_builder::mime::MimePart;
|
use mail_builder::mime::MimePart;
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
@@ -850,24 +850,7 @@ impl MimeFactory {
|
|||||||
} else if header_name == "to" {
|
} else if header_name == "to" {
|
||||||
protected_headers.push(header.clone());
|
protected_headers.push(header.clone());
|
||||||
if is_encrypted {
|
if is_encrypted {
|
||||||
let mut to_without_names = to
|
unprotected_headers.push(("To", hidden_recipients().into()));
|
||||||
.clone()
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(|header| match header {
|
|
||||||
Address::Address(mb) => Some(Address::Address(EmailAddress {
|
|
||||||
name: None,
|
|
||||||
email: mb.email,
|
|
||||||
})),
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
if to_without_names.is_empty() {
|
|
||||||
to_without_names.push(hidden_recipients());
|
|
||||||
}
|
|
||||||
unprotected_headers.push((
|
|
||||||
original_header_name,
|
|
||||||
Address::new_list(to_without_names).into(),
|
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
unprotected_headers.push(header.clone());
|
unprotected_headers.push(header.clone());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user