From cd3c2a6c6c9288643560706f3ebad6fb3067660f Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Wed, 3 Mar 2021 23:06:50 +0100 Subject: [PATCH] add test with multiple text parts the test has multiple text parts because the content text is signed and the mailinglist software wants to add some text (and cannot alter signed part without breaking the signature) --- src/dc_receive_imf.rs | 25 ++++++ ...ailinglist_with_mimepart_footer_signed.eml | 80 +++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 test-data/message/mailinglist_with_mimepart_footer_signed.eml diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 20e293402..07584af1c 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -3156,6 +3156,31 @@ mod tests { assert_eq!(chat.name, "Intern"); } + #[async_std::test] + async fn test_mailing_list_with_mimepart_footer_signed() { + let t = TestContext::new_alice().await; + t.set_config(Config::ShowEmails, Some("2")).await.unwrap(); + + dc_receive_imf( + &t, + include_bytes!("../test-data/message/mailinglist_with_mimepart_footer_signed.eml"), + "INBOX", + 1, + false, + ) + .await + .unwrap(); + let msg = t.get_last_msg().await; + assert_eq!(get_chat_msgs(&t, msg.chat_id, 0, None).await.len(), 1); + let text = msg.text.clone().unwrap(); + assert!(text.contains("content text")); + assert!(!text.contains("footer text")); + assert!(msg.has_html()); + let html = msg.get_id().get_html(&t).await.unwrap(); + assert!(html.contains("content text")); + assert!(!html.contains("footer text")); + } + #[async_std::test] async fn test_dont_show_tokens_in_contacts_list() { check_dont_show_in_contacts_list( diff --git a/test-data/message/mailinglist_with_mimepart_footer_signed.eml b/test-data/message/mailinglist_with_mimepart_footer_signed.eml new file mode 100644 index 000000000..df5f0945e --- /dev/null +++ b/test-data/message/mailinglist_with_mimepart_footer_signed.eml @@ -0,0 +1,80 @@ +Return-Path: +X-Original-To: bp@def.com +Delivered-To: m1234567@dd12345.kasserver.com +X-policyd-weight: using cached result; rate: -6.1 +Received: from mail.alfi.li (mail.alfi.li [85.14.254.25]) + by dd12345.kasserver.com (Postfix) with ESMTPS id 123456789598 + for ; Wed, 3 Mar 2021 01:01:25 +0100 (CET) +To: intern@lists.abc.de +References: <12345678-1234-1234-1234-123456789012@mr.de> +From: mr +Message-ID: <22222222-2222-2222-2222-222222222222@mr.de> +Date: Wed, 3 Mar 2021 01:01:11 +0100 +In-Reply-To: <12345678-1234-1234-1234-123456789012@mr.de> +Subject: Re: [Intern] more important stuff +X-BeenThere: intern@lists.abc.de +X-Mailman-Version: 2.1.29 +Precedence: list +List-Id: +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Content-Type: multipart/mixed; boundary="===============1234567890253566549==" +Errors-To: intern-bounces@lists.abc.de +Sender: "Intern" + +This is an OpenPGP/MIME signed message (RFC 4880 and 3156) +--===============1234567890253566549== +Content-Type: multipart/signed; micalg=pgp-sha256; + protocol="application/pgp-signature"; + boundary="2222222222nheMkezDtEaCy2H1M0Q3wtX" + +This is an OpenPGP/MIME signed message (RFC 4880 and 3156) +--2222222222nheMkezDtEaCy2H1M0Q3wtX +Content-Type: multipart/mixed; boundary="kpbXdSJRuZxNyB43gEja0tpvinYpituTJ"; + protected-headers="v1" +From: mr +To: intern@lists.abc.de +Message-ID: <22222222-2222-2222-2222-222222222222@mr.de> +Subject: Re: more important stuff +References: <12345678-1234-1234-1234-123456789012@mr.de> +In-Reply-To: <12345678-1234-1234-1234-123456789012@mr.de> + +--kpbXdSJRuZxNyB43gEja0tpvinYpituTJ +Content-Type: text/plain; charset=utf-8 +Content-Language: en-US +Content-Transfer-Encoding: quoted-printable + +On 02.03.21 22:41, mr wrote: +> quote to trigger has_html + +content text + +--kpbXdSJRuZxNyB43gEja0tpvinYpituTJ-- + +--2222222222nheMkezDtEaCy2H1M0Q3wtX +Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="OpenPGP_signature" + +-----BEGIN PGP SIGNATURE----- + +ws1234567890FiEEiGlkiQz18Vyq7pbiOWr31234567890A+0ccFAwAAAAAACgkQOWr3EM0fY5yc= +=oIB5 +-----END PGP SIGNATURE----- + +--2222222222nheMkezDtEaCy2H1M0Q3wtX-- + +--===============1234567890253566549== +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +footer text + +--===============1234567890253566549==-- +