Skip to content

Commit 365ccf1

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

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
@@ -717,8 +717,6 @@ def test_download_limit_chat_assignment(acfactory, tmp_path, n_accounts):
717717
contact = alice.create_contact(account)
718718
alice_group.add_contact(contact)
719719

720-
if n_accounts == 2:
721-
bob_chat_alice = bob.create_chat(alice)
722720
bob.set_config("download_limit", str(download_limit))
723721

724722
alice_group.send_text("hi")
@@ -734,15 +732,7 @@ def test_download_limit_chat_assignment(acfactory, tmp_path, n_accounts):
734732
alice_group.send_file(str(path))
735733
snapshot = bob.get_message_by_id(bob.wait_for_incoming_msg_event().msg_id).get_snapshot()
736734
assert snapshot.download_state == DownloadState.AVAILABLE
737-
if n_accounts > 2:
738-
assert snapshot.chat == bob_group
739-
else:
740-
# Group contains only Alice and Bob,
741-
# so partially downloaded messages are
742-
# hard to distinguish from private replies to group messages.
743-
#
744-
# Message may be a private reply, so we assign it to 1:1 chat with Alice.
745-
assert snapshot.chat == bob_chat_alice
735+
assert snapshot.chat == bob_group
746736

747737

748738
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: <[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
}

0 commit comments

Comments
 (0)