Fix: Recognize ndns that put the headers into "message/global-headers" part (Improve ndn detection) (#2598)

I sent a message, and the ndn (Non Delivery Notification) was not parsed correctly, so here comes
the fix and the test.
This commit is contained in:
Hocuri
2021-09-12 21:02:51 +02:00
committed by GitHub
parent 6f3dd7f0c2
commit 46956caf75
3 changed files with 114 additions and 5 deletions

View File

@@ -1141,11 +1141,11 @@ impl MimeMessage {
report: &mailparse::ParsedMail<'_>,
) -> Result<Option<FailureReport>> {
// parse as mailheaders
if let Some(original_msg) = report
.subparts
.iter()
.find(|p| p.ctype.mimetype.contains("rfc822") || p.ctype.mimetype == "message/global")
{
if let Some(original_msg) = report.subparts.iter().find(|p| {
p.ctype.mimetype.contains("rfc822")
|| p.ctype.mimetype == "message/global"
|| p.ctype.mimetype == "message/global-headers"
}) {
let report_body = original_msg.get_body_raw()?;
let (report_fields, _) = mailparse::parse_headers(&report_body)?;