Skip to content

Commit f74f55f

Browse files
link2xtiequidoo
authored andcommitted
feat: Hide To header in encrypted messages
1 parent 1cb0a25 commit f74f55f

File tree

5 files changed

+10
-37
lines changed

5 files changed

+10
-37
lines changed

src/chat/chat_tests.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -815,15 +815,6 @@ async fn test_self_talk() -> Result<()> {
815815
assert!(msg.get_showpadlock());
816816

817817
let sent_msg = t.pop_sent_msg().await;
818-
let payload = sent_msg.payload();
819-
// Make sure the `To` field contains the address and not
820-
// "undisclosed recipients".
821-
// Otherwise Delta Chat core <1.153.0 assigns the message
822-
// to the trash chat.
823-
assert_eq!(
824-
payload.match_indices("To: <[email protected]>\r\n").count(),
825-
1
826-
);
827818

828819
let t2 = TestContext::new_alice().await;
829820
t2.recv_msg(&sent_msg).await;

src/mimefactory.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use data_encoding::BASE32_NOPAD;
99
use deltachat_contact_tools::sanitize_bidi_characters;
1010
use iroh_gossip::proto::TopicId;
1111
use mail_builder::headers::HeaderType;
12-
use mail_builder::headers::address::{Address, EmailAddress};
12+
use mail_builder::headers::address::Address;
1313
use mail_builder::mime::MimePart;
1414
use tokio::fs;
1515

@@ -1000,24 +1000,7 @@ impl MimeFactory {
10001000
} else if header_name == "to" {
10011001
protected_headers.push(header.clone());
10021002
if is_encrypted {
1003-
let mut to_without_names = to
1004-
.clone()
1005-
.into_iter()
1006-
.filter_map(|header| match header {
1007-
Address::Address(mb) => Some(Address::Address(EmailAddress {
1008-
name: None,
1009-
email: mb.email,
1010-
})),
1011-
_ => None,
1012-
})
1013-
.collect::<Vec<_>>();
1014-
if to_without_names.is_empty() {
1015-
to_without_names.push(hidden_recipients());
1016-
}
1017-
unprotected_headers.push((
1018-
original_header_name,
1019-
Address::new_list(to_without_names).into(),
1020-
));
1003+
unprotected_headers.push(("To", hidden_recipients().into()));
10211004
} else {
10221005
unprotected_headers.push(header.clone());
10231006
}

src/mimefactory/mimefactory_tests.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,6 @@ async fn test_remove_member_bcc() -> Result<()> {
750750

751751
let bob_id = alice.add_or_lookup_contact_id(bob).await;
752752
let charlie_id = alice.add_or_lookup_contact_id(charlie).await;
753-
let charlie_contact = Contact::get_by_id(alice, charlie_id).await?;
754-
let charlie_addr = charlie_contact.get_addr();
755753

756754
let alice_chat_id = create_group(alice, "foo").await?;
757755
add_contact_to_chat(alice, alice_chat_id, bob_id).await?;
@@ -770,11 +768,11 @@ async fn test_remove_member_bcc() -> Result<()> {
770768
for to_addr in to.iter() {
771769
match to_addr {
772770
mailparse::MailAddr::Single(info) => {
773-
// Addresses should be of existing members (Alice and Bob) and not Charlie.
774-
assert_ne!(info.addr, charlie_addr);
771+
panic!("Single addresses are not expected here: {info:?}");
775772
}
776-
mailparse::MailAddr::Group(_) => {
777-
panic!("Group addresses are not expected here");
773+
mailparse::MailAddr::Group(info) => {
774+
assert_eq!(info.group_name, "hidden-recipients");
775+
assert_eq!(info.addrs, []);
778776
}
779777
}
780778
}

src/receive_imf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2575,7 +2575,7 @@ async fn is_probably_private_reply(
25752575
// should be assigned to the group chat. We restrict this exception to classical emails, as chat-group-messages
25762576
// contain a Chat-Group-Id header and can be sorted into the correct chat this way.
25772577

2578-
if mime_parser.recipients.len() != 1 {
2578+
if mime_parser.recipients.len() > 1 {
25792579
return Ok(false);
25802580
}
25812581

src/receive_imf/receive_imf_tests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4849,14 +4849,15 @@ async fn test_prefer_references_to_downloaded_msgs() -> Result<()> {
48494849
let received = bob.recv_msg(&sent).await;
48504850
assert_eq!(received.download_state, DownloadState::Available);
48514851
assert_ne!(received.chat_id, bob_chat_id);
4852-
assert_eq!(received.chat_id, bob.get_chat(alice).await.id);
4852+
let bob_alice_chat_id = bob.get_chat(alice).await.id;
4853+
assert_eq!(received.chat_id, bob_alice_chat_id);
48534854

48544855
let mut msg = Message::new(Viewtype::File);
48554856
msg.set_file_from_bytes(alice, "file", file_bytes, None)?;
48564857
let sent = alice.send_msg(alice_chat_id, &mut msg).await;
48574858
let received = bob.recv_msg(&sent).await;
48584859
assert_eq!(received.download_state, DownloadState::Available);
4859-
assert_eq!(received.chat_id, bob_chat_id);
4860+
assert_eq!(received.chat_id, bob_alice_chat_id);
48604861

48614862
Ok(())
48624863
}

0 commit comments

Comments
 (0)