diff --git a/src/dehtml.rs b/src/dehtml.rs index 39e18188a..354242757 100644 --- a/src/dehtml.rs +++ b/src/dehtml.rs @@ -23,11 +23,14 @@ struct Dehtml { /// Everything between
and
is usually metadata /// If this is > `0`, then we are inside a `
`. divs_since_quoted_content_div: u32, + /// All-Inkl just puts the quote into `
`. This count is + /// increased at each `
` and decreased at each `
`. + blockquotes_since_blockquote: u32, } impl Dehtml { fn line_prefix(&self) -> &str { - if self.divs_since_quoted_content_div > 0 { + if self.divs_since_quoted_content_div > 0 || self.blockquotes_since_blockquote > 0 { "> " } else { "" @@ -67,7 +70,7 @@ pub fn dehtml(buf: &str) -> Option { None } -pub fn dehtml_quick_xml(buf: &str) -> String { +fn dehtml_quick_xml(buf: &str) -> String { let buf = buf.trim().trim_start_matches(""); let mut dehtml = Dehtml { @@ -76,6 +79,7 @@ pub fn dehtml_quick_xml(buf: &str) -> String { last_href: None, divs_since_quote_div: 0, divs_since_quoted_content_div: 0, + blockquotes_since_blockquote: 0, }; let mut reader = quick_xml::Reader::from_str(buf); @@ -179,6 +183,7 @@ fn dehtml_endtag_cb(event: &BytesEnd, dehtml: &mut Dehtml) { dehtml.strbuilder += "_"; } } + "blockquote" => pop_tag(&mut dehtml.blockquotes_since_blockquote), _ => {} } } @@ -241,6 +246,7 @@ fn dehtml_starttag_cb( dehtml.strbuilder += "_"; } } + "blockquote" => dehtml.blockquotes_since_blockquote += 1, _ => {} } } diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 47df2b993..dd9829ec7 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -2744,6 +2744,19 @@ On 2020-10-25, Bob wrote: assert_eq!(mimeparser.parts[0].param.get(Param::Quote).unwrap(), "Now?"); } + #[async_std::test] + async fn test_allinkl_blockquote() { + // all-inkl.com puts quotes into `
`. + let t = TestContext::new().await; + let raw = include_bytes!("../test-data/message/allinkl-quote.eml"); + let mimeparser = MimeMessage::from_bytes(&t, raw).await.unwrap(); + assert!(mimeparser.parts[0].msg.starts_with("It's 1.0.")); + assert_eq!( + mimeparser.parts[0].param.get(Param::Quote).unwrap(), + "What's the version?" + ); + } + #[async_std::test] async fn test_add_subj_to_multimedia_msg() { let t = TestContext::new_alice().await; diff --git a/test-data/message/allinkl-quote.eml b/test-data/message/allinkl-quote.eml new file mode 100644 index 000000000..03b729b5d --- /dev/null +++ b/test-data/message/allinkl-quote.eml @@ -0,0 +1,46 @@ +Return-Path: +Delivered-To: bob@example.org +Received: from hq5.merlinux.eu + by hq5.merlinux.eu with LMTP + id eHU/Co4EUmBAQQAAPzvFDg + (envelope-from ) + for ; Wed, 17 Mar 2021 14:30:54 +0100 +Received: from dd37930.kasserver.com (dd37930.kasserver.com [85.13.154.127]) + by hq5.merlinux.eu (Postfix) with ESMTPS id CB5D927A0071 + for ; Wed, 17 Mar 2021 14:30:53 +0100 (CET) +Received: from dd37930.kasserver.com (dd0805.kasserver.com [85.13.161.253]) + by dd37930.kasserver.com (Postfix) with ESMTPSA id 724E853C0979 + for ; Wed, 17 Mar 2021 14:30:53 +0100 (CET) +MIME-Version: 1.0 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +X-SenderIP: 217.80.3.233 +User-Agent: ALL-INKL Webmail 2.11 +In-Reply-To: +References: +Subject: Re: Message from Hocuri +From: alice@example.org +To: bob@example.org +Message-Id: <20210317133053.724E853C0979@dd37930.kasserver.com> +Date: Wed, 17 Mar 2021 14:30:53 +0100 (CET) + +html,body{background-color:#fff;color:#333;line-heig= +ht:1.4;font-family:sans-serif,Arial,Verdana,Trebuchet MS;}

It's 1.0.

+
+

Hocuri schrieb am 17.03.2021 14:25 (GMT +01:00):

+
+
What's the version?
+
+--=20
+Sent with my Delta Chat Messenger: https://del=
+ta.chat
+
+
+
+