From a69556a63fda07bbeda3425318142b97539214d0 Mon Sep 17 00:00:00 2001 From: Oliver Ford Date: Mon, 18 Mar 2024 21:27:55 +0000 Subject: [PATCH] Fix error on malformed spam multipart msg --- notmuch-more/src/parse/body.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/notmuch-more/src/parse/body.rs b/notmuch-more/src/parse/body.rs index 03f47e8..96122c6 100644 --- a/notmuch-more/src/parse/body.rs +++ b/notmuch-more/src/parse/body.rs @@ -31,6 +31,7 @@ pub(crate) fn parse_body_part(part: &mailparse::ParsedMail) -> Result match part.ctype.mimetype.as_str() { @@ -78,7 +79,8 @@ pub(crate) fn parse_body_part(part: &mailparse::ParsedMail) -> Result { - let mut first = parse_body_part(&part.subparts[0])?; + let mut first = + parse_body_part(part.subparts.first().ok_or(err_multipart_no_subpart)?)?; first.alternatives = part.subparts[1..] .iter() .map(parse_body_part) @@ -87,7 +89,8 @@ pub(crate) fn parse_body_part(part: &mailparse::ParsedMail) -> Result { - let mut first = parse_body_part(&part.subparts[0])?; + let mut first = + parse_body_part(part.subparts.first().ok_or(err_multipart_no_subpart)?)?; first.extra = part.subparts[1..] .iter() .map(parse_body_part) @@ -97,7 +100,8 @@ pub(crate) fn parse_body_part(part: &mailparse::ParsedMail) -> Result { - let mut first = parse_body_part(&part.subparts[0])?; + let mut first = + parse_body_part(part.subparts.first().ok_or(err_multipart_no_subpart)?)?; first.signature = Some(Box::new(parse_body_part( part.subparts[1..] .iter()