From e3e2adeea5fa27d659573ad377a075d6a1a7fcae Mon Sep 17 00:00:00 2001 From: Hocuri Date: Fri, 28 May 2021 20:02:46 +0200 Subject: [PATCH] Fix all outgoing messages popping up in selfchat (#2456) Fix https://github.com/deltachat/deltachat-android/issues/1940, fix https://github.com/deltachat/deltachat-core-rust/issues/2220 (I assume these are the same bug) The problem was: - Gmail adds a header `Bcc: ` to our bcc-self message - `to_id` was just set to the first recipient, in this case _self_ - it was seen that `to_id` is _self_, so it's a self-sent message --- src/dc_receive_imf.rs | 29 +++++++++++++++++++++++++++++ src/mimeparser.rs | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 8fcadd664..a4642edb6 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -3986,4 +3986,33 @@ YEAAAAAA!. .await, ); } + + #[async_std::test] + async fn test_dont_show_all_outgoing_msgs_in_self_chat() { + // Regression test for https://github.com/deltachat/deltachat-android/issues/1940: + // Some servers add a `Bcc: ` header, which caused all outgoing messages to + // be shown in the self-chat. + let t = TestContext::new_alice().await; + + dc_receive_imf( + &t, + b"Bcc: alice@example.com +Received: from [127.0.0.1] +Subject: s +Chat-Version: 1.0 +Message-ID: +To: +From: + +Message content", + "Inbox", + 1, + false, + ) + .await + .unwrap(); + + let msg = t.get_last_msg().await; + assert_ne!(msg.chat_id, t.get_self_chat().await.id); + } } diff --git a/src/mimeparser.rs b/src/mimeparser.rs index d7942ab90..4582157b9 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -1585,7 +1585,7 @@ fn get_attachment_filename( /// Returned addresses are normalized and lowercased. pub(crate) fn get_recipients(headers: &[MailHeader]) -> Vec { get_all_addresses_from_header(headers, |header_key| { - header_key == "to" || header_key == "cc" || header_key == "bcc" + header_key == "to" || header_key == "cc" }) }