Skip to content

Commit 9f404f9

Browse files
link2xtiequidoo
authored andcommitted
feat: Hide To header in encrypted messages
1 parent 8eef79f commit 9f404f9

File tree

4 files changed

+7
-45
lines changed

4 files changed

+7
-45
lines changed

deltachat-rpc-client/tests/test_something.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,6 @@ def test_download_limit_chat_assignment(acfactory, tmp_path, n_accounts):
661661
contact = alice.create_contact(account)
662662
alice_group.add_contact(contact)
663663

664-
if n_accounts == 2:
665-
bob_chat_alice = bob.create_chat(alice)
666664
bob.set_config("download_limit", str(download_limit))
667665

668666
alice_group.send_text("hi")
@@ -678,15 +676,7 @@ def test_download_limit_chat_assignment(acfactory, tmp_path, n_accounts):
678676
alice_group.send_file(str(path))
679677
snapshot = bob.wait_for_incoming_msg().get_snapshot()
680678
assert snapshot.download_state == DownloadState.AVAILABLE
681-
if n_accounts > 2:
682-
assert snapshot.chat == bob_group
683-
else:
684-
# Group contains only Alice and Bob,
685-
# so partially downloaded messages are
686-
# hard to distinguish from private replies to group messages.
687-
#
688-
# Message may be a private reply, so we assign it to 1:1 chat with Alice.
689-
assert snapshot.chat == bob_chat_alice
679+
assert snapshot.chat == bob_group
690680

691681

692682
def test_markseen_contact_request(acfactory):

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: <alice@example.org>\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

@@ -993,24 +993,7 @@ impl MimeFactory {
993993
} else if header_name == "to" {
994994
protected_headers.push(header.clone());
995995
if is_encrypted {
996-
let mut to_without_names = to
997-
.clone()
998-
.into_iter()
999-
.filter_map(|header| match header {
1000-
Address::Address(mb) => Some(Address::Address(EmailAddress {
1001-
name: None,
1002-
email: mb.email,
1003-
})),
1004-
_ => None,
1005-
})
1006-
.collect::<Vec<_>>();
1007-
if to_without_names.is_empty() {
1008-
to_without_names.push(hidden_recipients());
1009-
}
1010-
unprotected_headers.push((
1011-
original_header_name,
1012-
Address::new_list(to_without_names).into(),
1013-
));
996+
unprotected_headers.push(("To", hidden_recipients().into()));
1014997
} else {
1015998
unprotected_headers.push(header.clone());
1016999
}

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
}

0 commit comments

Comments
 (0)