Skip to content

Commit fb04319

Browse files
committed
fix: make protected Message-ID take precedence over X-Microsoft-Original-Message-ID
1 parent 35cc823 commit fb04319

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/mimeparser.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,18 @@ impl MimeMessage {
275275
}
276276
}
277277

278+
// Overwrite Message-ID with X-Microsoft-Original-Message-ID.
279+
// However if we later find Message-ID in the protected part,
280+
// it will overwrite both.
281+
if let Some(microsoft_message_id) =
282+
headers.remove(HeaderDef::XMicrosoftOriginalMessageId.get_headername())
283+
{
284+
headers.insert(
285+
HeaderDef::MessageId.get_headername().to_string(),
286+
microsoft_message_id,
287+
);
288+
}
289+
278290
// Remove headers that are allowed _only_ in the encrypted+signed part. It's ok to leave
279291
// them in signed-only emails, but has no value currently.
280292
Self::remove_secured_headers(&mut headers);
@@ -1379,8 +1391,7 @@ impl MimeMessage {
13791391
}
13801392

13811393
pub(crate) fn get_rfc724_mid(&self) -> Option<String> {
1382-
self.get_header(HeaderDef::XMicrosoftOriginalMessageId)
1383-
.or_else(|| self.get_header(HeaderDef::MessageId))
1394+
self.get_header(HeaderDef::MessageId)
13841395
.and_then(|msgid| parse_message_id(msgid).ok())
13851396
}
13861397

0 commit comments

Comments
 (0)