From eb29f9c4c1330ca60a7bc61d34d138a62efe6d3f Mon Sep 17 00:00:00 2001 From: Hocuri Date: Mon, 15 Jun 2020 16:07:02 +0200 Subject: [PATCH] Parse testrun NDNs --- src/dc_receive_imf.rs | 12 ++++ src/mimeparser.rs | 2 +- test-data/message/testrun_ndn.eml | 107 ++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 test-data/message/testrun_ndn.eml diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index bbf512bcf..5691d314a 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -2334,6 +2334,18 @@ mod tests { ); } + #[async_std::test] + async fn test_parse_ndn_testrun() { + test_parse_ndn( + "alice@testrun.org", + "hcksocnsofoejx@five.chat", + "Mr.A7pTA5IgrUA.q4bP41vAJOp@testrun.org", + include_bytes!("../test-data/message/testrun_ndn.eml"), + "Undelivered Mail Returned to Sender – This is the mail system at host hq5.merlinux.eu.\n\nI\'m sorry to have to inform you that your message could not\nbe delivered to one or more recipients. It\'s attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can\ndelete your own text from the attached returned message.\n\n The mail system\n\n: host mail.five.chat[195.62.125.103] said: 550 5.1.1\n : Recipient address rejected: User unknown in\n virtual mailbox table (in reply to RCPT TO command)" + ) + .await; + } + #[async_std::test] async fn test_parse_ndn_yahoo() { test_parse_ndn( diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 1ac3e67c7..0f46aa0ba 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -866,7 +866,7 @@ impl MimeMessage { if let Some(original_msg) = report .subparts .iter() - .find(|p| p.ctype.mimetype.contains("rfc822")) + .find(|p| p.ctype.mimetype.contains("rfc822") || p.ctype.mimetype == "message/global") { let report_body = original_msg.get_body_raw()?; let (report_fields, _) = mailparse::parse_headers(&report_body)?; diff --git a/test-data/message/testrun_ndn.eml b/test-data/message/testrun_ndn.eml new file mode 100644 index 000000000..abbed2e94 --- /dev/null +++ b/test-data/message/testrun_ndn.eml @@ -0,0 +1,107 @@ +Return-Path: <> +Delivered-To: alice@testrun.org +Received: from hq5.merlinux.eu + by hq5.merlinux.eu (Dovecot) with LMTP id Ye02K6PB5F43cQAAPzvFDg + for ; Sat, 13 Jun 2020 14:08:03 +0200 +Received: by hq5.merlinux.eu (Postfix) + id 9EBE627A0B2E; Sat, 13 Jun 2020 14:08:03 +0200 (CEST) +Date: Sat, 13 Jun 2020 14:08:03 +0200 (CEST) +From: MAILER-DAEMON@hq5.merlinux.eu (Mail Delivery System) +Subject: Undelivered Mail Returned to Sender +To: alice@testrun.org +Auto-Submitted: auto-replied +MIME-Version: 1.0 +Content-Type: multipart/report; report-type=delivery-status; + boundary="CDB8D27A0B2C.1592050083/hq5.merlinux.eu" +Content-Transfer-Encoding: 8bit +Message-Id: <20200613120803.9EBE627A0B2E@hq5.merlinux.eu> + +This is a MIME-encapsulated message. + +--CDB8D27A0B2C.1592050083/hq5.merlinux.eu +Content-Description: Notification +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8bit + +This is the mail system at host hq5.merlinux.eu. + +I'm sorry to have to inform you that your message could not +be delivered to one or more recipients. It's attached below. + +For further assistance, please send mail to postmaster. + +If you do so, please include this problem report. You can +delete your own text from the attached returned message. + + The mail system + +: host mail.five.chat[195.62.125.103] said: 550 5.1.1 + : Recipient address rejected: User unknown in + virtual mailbox table (in reply to RCPT TO command) + +--CDB8D27A0B2C.1592050083/hq5.merlinux.eu +Content-Description: Delivery report +Content-Type: message/global-delivery-status +Content-Transfer-Encoding: 8bit + +Reporting-MTA: dns; hq5.merlinux.eu +X-Postfix-Queue-ID: CDB8D27A0B2C +X-Postfix-Sender: rfc822; alice@testrun.org +Arrival-Date: Sat, 13 Jun 2020 14:08:01 +0200 (CEST) + +Final-Recipient: rfc822; hcksocnsofoejx@five.chat +Original-Recipient: rfc822;hcksocnsofoejx@five.chat +Action: failed +Status: 5.1.1 +Remote-MTA: dns; mail.five.chat +Diagnostic-Code: smtp; 550 5.1.1 : Recipient address + rejected: User unknown in virtual mailbox table + +--CDB8D27A0B2C.1592050083/hq5.merlinux.eu +Content-Description: Undelivered Message +Content-Type: message/global +Content-Transfer-Encoding: 8bit + +Return-Path: +Received: from localhost (p200300edb723070079835ce22985a199.dip0.t-ipconnect.de [IPv6:2003:ed:b723:700:7983:5ce2:2985:a199]) + by hq5.merlinux.eu (Postfix) with UTF8SMTPSA id CDB8D27A0B2C; + Sat, 13 Jun 2020 14:08:01 +0200 (CEST) +DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=testrun.org; + s=testrun; t=1592050082; + bh=Kvhta0OMsTRVC7OlaAqo68TBE0KuGBv4vUBp6Ez/7VY=; + h=Subject:References:In-Reply-To:Date:To:From:From; + b=Ql60JEGFXLNvjsyihATw2z34ct++8xZvTPNw0snXe6+oqdqsRZJ9tWNDTxOgx8Iqf + HQ4puBVGcWjIlszYQVLlq3APi04o2ep3GrD8EF0J0GpDdW8yw6wCos6Q8r+TWmXwET + kGXHTRPVaUIqZF2i/utypxMfd1ua0S3jBDnIXTe/p2+XvfC3Cf3hZGW+FQ/Zd7G8Vh + /U2rgX5BTIGf26ZCbmcMaXWkftgv6+yns0AmzorV9yB+EhTkWIUjk+C25bRtMbJ5mZ + 93dwdr+sXrrSZLSi+LBqc57Dv9j4p/SUmB4zPlvfUv7/bqLi36pypvtCJ5Ul8UEXSb + XNFZPaEl+mwjA== +Content-Type: text/plain; charset=utf-8 +Chat-Disposition-Notification-To: alice@testrun.org +Subject: =?utf-8?q?Message_from_hocuri1=40testrun=2Eorg?= +MIME-Version: 1.0 +References: + +In-Reply-To: +Date: Sat, 13 Jun 2020 12:08:01 +0000 +X-Mailer: Delta Chat Core 1.35.0/Android 1.9.5 +Chat-Version: 1.0 +Autocrypt: addr=alice@testrun.org; prefer-encrypt=mutual; + keydata=xjMEXt3z1xYJKwYBBAHaRw8BAQdAf6MctU/8cmEqwEN9VFZ3gHBFIxKiEaARZl1DFUkI7e + rNFTxob2N1cmkxQHRlc3RydW4ub3JnPsKLBBAWCAAzAhkBBQJe3fPXAhsDBAsJCAcGFQgJCgsCAxYC + ARYhBIZ3ajRUkki89+04sgctAtaIXygAAAoJEActAtaIXygAG2IA/1nTmmmkHAc1Bjtx2FOstbaS+N + XHjxaK+hkoWllsyhz0AQDJJ1++u7jVZPRn/j1LlByrT3Jv/D1aY14J5rjj+ADVBM44BF7d89cSCisG + AQQBl1UBBQEBB0DpSTaZ30dAVwM9PkBe2h+gFyxn9HSorP4XCHJu/lIdPAMBCAfCeAQYFggAIAUCXt + 3z1wIbDBYhBIZ3ajRUkki89+04sgctAtaIXygAAAoJEActAtaIXygA2QkA/16toWCtseYKw8G1X2j7 + xYR3Cyabq37hgbesDOThIIzNAP0UCUS8mnunmkS5adEbftRaDi2JZoGxDw46jtJJ2+13Cw== +Message-ID: +To: +From: + +F + +-- +Sent with my Delta Chat Messenger: https://delta.chat + + +--CDB8D27A0B2C.1592050083/hq5.merlinux.eu--