mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
fix: Prefer encrypted List-Id header (#6983)
If there is an encrypted List-Id header, it should be preferred over an unencrypted List-Id header. Part of #6884
This commit is contained in:
@@ -5,6 +5,7 @@ use crate::ephemeral::Timer;
|
||||
use crate::headerdef::HeaderDef;
|
||||
use crate::imex::{ImexMode, has_backup, imex};
|
||||
use crate::message::{MessengerMessage, delete_msgs};
|
||||
use crate::mimeparser;
|
||||
use crate::receive_imf::receive_imf;
|
||||
use crate::test_utils::{
|
||||
AVATAR_64x64_BYTES, AVATAR_64x64_DEDUPLICATED, TestContext, TestContextManager,
|
||||
@@ -2889,6 +2890,52 @@ async fn test_block_broadcast() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Tests that a List-Id header in the encrypted part
|
||||
/// overrides a List-Id header in the unencrypted part,
|
||||
/// and that the List-Id isn't visible in the unencrypted part.
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_broadcast_channel_protected_listid() -> Result<()> {
|
||||
let mut tcm = TestContextManager::new();
|
||||
let alice = &tcm.alice().await;
|
||||
let bob = &tcm.bob().await;
|
||||
let alice_bob_contact_id = alice.add_or_lookup_contact_id(bob).await;
|
||||
|
||||
tcm.section("Create a broadcast channel with Bob, and send a message");
|
||||
let alice_chat_id = create_broadcast(alice, "My Channel".to_string()).await?;
|
||||
add_contact_to_chat(alice, alice_chat_id, alice_bob_contact_id).await?;
|
||||
let mut sent = alice.send_text(alice_chat_id, "Hi somebody").await;
|
||||
|
||||
assert!(!sent.payload.contains("List-ID"));
|
||||
// Do the counter check that the Message-Id header is present:
|
||||
assert!(sent.payload.contains("Message-ID"));
|
||||
|
||||
// Check that Delta Chat ignores an injected List-ID header:
|
||||
let new_payload = sent.payload.replace(
|
||||
"Date: ",
|
||||
"List-ID: some wrong listid that would make things fail\nDate: ",
|
||||
);
|
||||
assert_ne!(&sent.payload, &new_payload);
|
||||
sent.payload = new_payload;
|
||||
|
||||
let alice_list_id = Chat::load_from_db(alice, sent.load_from_db().await.chat_id)
|
||||
.await?
|
||||
.grpid;
|
||||
|
||||
let parsed = mimeparser::MimeMessage::from_bytes(bob, sent.payload.as_bytes(), None).await?;
|
||||
assert_eq!(
|
||||
parsed.get_mailinglist_header().unwrap(),
|
||||
format!("My Channel <{}>", alice_list_id)
|
||||
);
|
||||
|
||||
let rcvd = bob.recv_msg(&sent).await;
|
||||
assert_eq!(
|
||||
Chat::load_from_db(bob, rcvd.chat_id).await?.grpid,
|
||||
alice_list_id
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_create_for_contact_with_blocked() -> Result<()> {
|
||||
let t = TestContext::new().await;
|
||||
|
||||
@@ -2007,6 +2007,7 @@ fn is_known(key: &str) -> bool {
|
||||
| "references"
|
||||
| "subject"
|
||||
| "secure-join"
|
||||
| "list-id"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user