From 99f2680e2cd12a078fe44e1d74f695d5a4cb1b69 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 30 Jan 2022 00:40:05 +0100 Subject: [PATCH] fix splitting off text from webxdc messages moreover, make the split check exhaustive to avoid the same error on the next added Viewtype. --- CHANGELOG.md | 3 +++ src/mimeparser.rs | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 106868563..c6170c32c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ - refactorings #3023 - remove direct dependency on `byteorder` crate #3031 +### Fixes +- fix splitting off text from webxdc messages #3032 + ## 1.72.0 diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 4e98b8fab..e39191890 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -403,16 +403,18 @@ impl MimeMessage { #[allow(clippy::indexing_slicing)] fn squash_attachment_parts(&mut self) { if let [textpart, filepart] = &self.parts[..] { - let need_drop = { - textpart.typ == Viewtype::Text - && (filepart.typ == Viewtype::Image - || filepart.typ == Viewtype::Gif - || filepart.typ == Viewtype::Sticker - || filepart.typ == Viewtype::Audio - || filepart.typ == Viewtype::Voice - || filepart.typ == Viewtype::Video - || filepart.typ == Viewtype::File) - }; + let need_drop = textpart.typ == Viewtype::Text + && match filepart.typ { + Viewtype::Image + | Viewtype::Gif + | Viewtype::Sticker + | Viewtype::Audio + | Viewtype::Voice + | Viewtype::Video + | Viewtype::File + | Viewtype::Webxdc => true, + Viewtype::Unknown | Viewtype::Text | Viewtype::VideochatInvitation => false, + }; if need_drop { let mut filepart = self.parts.swap_remove(1);