mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-05 17:15:12 +00:00
default Content-Type to text/plain for not multipart messages (#357)
* Default Content-Type to text/plain for not multipart messages Parse body of messages without subparts as text/plain if Content-Type header is not set. * narrow check for defaulting to `text/plain` take message body as `text/plain` only if message has only one part and has no `Content-Type` header Co-authored-by: Clément DOUIN <soywod@users.noreply.github.com>
This commit is contained in:
parent
6d154abcb5
commit
b7157573f2
|
@ -55,7 +55,12 @@ impl Parts {
|
|||
part: &'a mailparse::ParsedMail<'a>,
|
||||
) -> Result<Self> {
|
||||
let mut parts = vec![];
|
||||
build_parts_map_rec(account, part, &mut parts)?;
|
||||
if part.subparts.is_empty() && part.get_headers().get_first_value("content-type").is_none() {
|
||||
let content = part.get_body().unwrap_or_default();
|
||||
parts.push(Part::TextPlain(TextPlainPart { content }))
|
||||
} else {
|
||||
build_parts_map_rec(account, part, &mut parts)?;
|
||||
}
|
||||
Ok(Self(parts))
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +110,7 @@ fn build_parts_map_rec(
|
|||
} else if ctype.starts_with("text/html") {
|
||||
parts.push(Part::TextHtml(TextHtmlPart { content }))
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue