diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 1e3a1a896..77bf86ddb 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -259,6 +259,7 @@ impl MimeMessage { }; parser.parse_mime_recursive(context, &mail).await?; parser.maybe_remove_bad_parts(); + parser.maybe_remove_inline_mailinglist_footer(); parser.heuristically_parse_ndn(context).await; parser.parse_headers(context); @@ -1084,6 +1085,28 @@ impl MimeMessage { } } + /// Remove unwanted, additional text parts used for mailing list footer. + /// Some mailinglist software add footers as separate mimeparts + /// eg. when the user-edited-content is html. + /// As these footers would appear as repeated, separate text-bubbles, + /// we remove them. + fn maybe_remove_inline_mailinglist_footer(&mut self) { + if self.is_mailinglist_message() { + let text_part_cnt = self + .parts + .iter() + .filter(|p| p.typ == Viewtype::Text) + .count(); + if text_part_cnt == 2 { + if let Some(last_part) = self.parts.last() { + if last_part.typ == Viewtype::Text { + self.parts.pop(); + } + } + } + } + } + /// Some providers like GMX and Yahoo do not send standard NDNs (Non Delivery notifications). /// If you improve heuristics here you might also have to change prefetch_should_download() in imap/mod.rs. /// Also you should add a test in dc_receive_imf.rs (there already are lots of test_parse_ndn_* tests).