Add .eml example with odd behavior (#88)

* Add .eml example with odd behavior

* Parse malformed, non-multipart, single text/plain messages best-effort as if text is not malformed
This commit is contained in:
sftse
2025-01-25 15:14:19 +01:00
committed by GitHub
parent ed16429bcc
commit e97d14ad89
6 changed files with 150 additions and 7 deletions
+11 -1
View File
@@ -250,7 +250,9 @@ impl MessageParser {
let mut is_encoding_problem = offset_end == usize::MAX;
if is_encoding_problem {
encoding = Encoding::None;
mime_type = MimeType::TextOther;
if mime_type != MimeType::TextPlain {
mime_type = MimeType::TextOther;
}
is_inline = false;
is_text = true;
@@ -278,6 +280,14 @@ impl MessageParser {
&& (mime_type == MimeType::Inline
|| content_type.map_or(true, |c| !c.has_attribute("name"))));
// if message consists of single text/plain part, classify as text regardless
// of encoding issues: see malformed/018.eml
let is_inline = is_inline
|| state.parts == 1
&& state.mime_type == MimeType::Message
&& mime_type == MimeType::TextPlain
&& is_encoding_problem;
let (add_to_html, add_to_text) =
if let MimeType::MultipartAlternative = state.mime_type {
match mime_type {