Skip to content

Commit 2a49a83

Browse files
committed
fix: image/*, audio/*, video/* are not attachments when found in both text and html parts
RFC8621 section 4.1.4 The additional is_multipart heuristic prevents the tests for malformed .eml from failing.
1 parent ba4517c commit 2a49a83

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/parsers/message.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,10 @@ impl MessageParser {
314314
message.text_body.push(message.parts.len());
315315
}
316316

317-
let is_html = mime_type == MimeType::TextHtml;
318-
319-
if !is_text || !add_to_html && is_html || !add_to_text && !is_html {
317+
if !is_multipart && !add_to_text && !add_to_html
318+
|| (is_multipart || mime_type == MimeType::Inline)
319+
&& (!add_to_text || !add_to_html)
320+
{
320321
message.attachments.push(message.parts.len());
321322
}
322323

@@ -338,6 +339,8 @@ impl MessageParser {
338339
(Cow::Borrowed(bytes), None) => String::from_utf8_lossy(bytes),
339340
};
340341

342+
let is_html = mime_type == MimeType::TextHtml;
343+
341344
if is_html {
342345
PartType::Html(text)
343346
} else {

0 commit comments

Comments
 (0)