mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 17:06:35 +03:00
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.
This commit is contained in:
@@ -288,9 +288,7 @@ impl MimeMessage {
|
|||||||
if let Some(part) = part.subparts.first() {
|
if let Some(part) = part.subparts.first() {
|
||||||
for field in &part.headers {
|
for field in &part.headers {
|
||||||
let key = field.get_key().to_lowercase();
|
let key = field.get_key().to_lowercase();
|
||||||
|
if !headers.contains_key(&key) && is_hidden(&key) || key == "message-id" {
|
||||||
// For now only avatar headers can be hidden.
|
|
||||||
if !headers.contains_key(&key) && is_hidden(&key) {
|
|
||||||
headers.insert(key.to_string(), field.get_value());
|
headers.insert(key.to_string(), field.get_value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1918,6 +1918,29 @@ This is the epilogue. It is also to be ignored.";
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn test_hidden_message_id() {
|
||||||
|
let t = &TestContext::new().await;
|
||||||
|
let raw = br#"Message-ID: bar@example.org
|
||||||
|
Date: Sun, 08 Dec 2019 23:12:55 +0000
|
||||||
|
To: <alice@example.org>
|
||||||
|
From: <tunis4@example.org>
|
||||||
|
Content-Type: multipart/mixed; boundary="luTiGu6GBoVLCvTkzVtmZmwsmhkNMw"
|
||||||
|
|
||||||
|
|
||||||
|
--luTiGu6GBoVLCvTkzVtmZmwsmhkNMw
|
||||||
|
Message-ID: foo@example.org
|
||||||
|
Content-Type: text/plain; charset=utf-8
|
||||||
|
|
||||||
|
Message with a correct Message-ID hidden header
|
||||||
|
|
||||||
|
--luTiGu6GBoVLCvTkzVtmZmwsmhkNMw--
|
||||||
|
"#;
|
||||||
|
|
||||||
|
let message = MimeMessage::from_bytes(t, &raw[..], None).await.unwrap();
|
||||||
|
assert_eq!(message.get_rfc724_mid().unwrap(), "foo@example.org");
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_chat_edit_imf_header() -> Result<()> {
|
async fn test_chat_edit_imf_header() -> Result<()> {
|
||||||
let mut tcm = TestContextManager::new();
|
let mut tcm = TestContextManager::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user