fix splitting off text from webxdc messages

moreover, make the split check exhaustive
to avoid the same error on the next added Viewtype.
This commit is contained in:
B. Petersen
2022-01-30 00:40:05 +01:00
committed by bjoern
parent 7a9a323bac
commit 99f2680e2c
2 changed files with 15 additions and 10 deletions

View File

@@ -8,6 +8,9 @@
- refactorings #3023 - refactorings #3023
- remove direct dependency on `byteorder` crate #3031 - remove direct dependency on `byteorder` crate #3031
### Fixes
- fix splitting off text from webxdc messages #3032
## 1.72.0 ## 1.72.0

View File

@@ -403,16 +403,18 @@ impl MimeMessage {
#[allow(clippy::indexing_slicing)] #[allow(clippy::indexing_slicing)]
fn squash_attachment_parts(&mut self) { fn squash_attachment_parts(&mut self) {
if let [textpart, filepart] = &self.parts[..] { if let [textpart, filepart] = &self.parts[..] {
let need_drop = { let need_drop = textpart.typ == Viewtype::Text
textpart.typ == Viewtype::Text && match filepart.typ {
&& (filepart.typ == Viewtype::Image Viewtype::Image
|| filepart.typ == Viewtype::Gif | Viewtype::Gif
|| filepart.typ == Viewtype::Sticker | Viewtype::Sticker
|| filepart.typ == Viewtype::Audio | Viewtype::Audio
|| filepart.typ == Viewtype::Voice | Viewtype::Voice
|| filepart.typ == Viewtype::Video | Viewtype::Video
|| filepart.typ == Viewtype::File) | Viewtype::File
}; | Viewtype::Webxdc => true,
Viewtype::Unknown | Viewtype::Text | Viewtype::VideochatInvitation => false,
};
if need_drop { if need_drop {
let mut filepart = self.parts.swap_remove(1); let mut filepart = self.parts.swap_remove(1);