Skip to content

Commit 82f6103

Browse files
committed
fix: Prefer hidden Message-ID header if any
Delta Chat already adds hidden Message-ID header because some servers mess up with it, so it should be preferred.
1 parent 4ec20ab commit 82f6103

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/mimeparser.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,7 @@ impl MimeMessage {
288288
if let Some(part) = part.subparts.first() {
289289
for field in &part.headers {
290290
let key = field.get_key().to_lowercase();
291-
292-
// For now only avatar headers can be hidden.
293-
if !headers.contains_key(&key) && is_hidden(&key) {
291+
if !headers.contains_key(&key) && is_hidden(&key) || key == "message-id" {
294292
headers.insert(key.to_string(), field.get_value());
295293
}
296294
}

src/mimeparser/mimeparser_tests.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,6 +1918,29 @@ This is the epilogue. It is also to be ignored.";
19181918
);
19191919
}
19201920

1921+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
1922+
async fn test_hidden_message_id() {
1923+
let t = &TestContext::new().await;
1924+
let raw = br#"Message-ID: bar@example.org
1925+
Date: Sun, 08 Dec 2019 23:12:55 +0000
1926+
To: <alice@example.org>
1927+
From: <tunis4@example.org>
1928+
Content-Type: multipart/mixed; boundary="luTiGu6GBoVLCvTkzVtmZmwsmhkNMw"
1929+
1930+
1931+
--luTiGu6GBoVLCvTkzVtmZmwsmhkNMw
1932+
Message-ID: foo@example.org
1933+
Content-Type: text/plain; charset=utf-8
1934+
1935+
Message with a correct Message-ID hidden header
1936+
1937+
--luTiGu6GBoVLCvTkzVtmZmwsmhkNMw--
1938+
"#;
1939+
1940+
let message = MimeMessage::from_bytes(t, &raw[..], None).await.unwrap();
1941+
assert_eq!(message.get_rfc724_mid().unwrap(), "foo@example.org");
1942+
}
1943+
19211944
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
19221945
async fn test_chat_edit_imf_header() -> Result<()> {
19231946
let mut tcm = TestContextManager::new();

0 commit comments

Comments
 (0)