Skip to content

Commit 5b1e583

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 5b1e583

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/parsers/message.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,10 @@ impl MessageParser {
316316

317317
let is_html = mime_type == MimeType::TextHtml;
318318

319-
if !is_text || !add_to_html && is_html || !add_to_text && !is_html {
319+
if !is_multipart && !add_to_text && !add_to_html
320+
|| (is_multipart || mime_type == MimeType::Inline)
321+
&& (!add_to_text || !add_to_html)
322+
{
320323
message.attachments.push(message.parts.len());
321324
}
322325

@@ -338,6 +341,8 @@ impl MessageParser {
338341
(Cow::Borrowed(bytes), None) => String::from_utf8_lossy(bytes),
339342
};
340343

344+
let is_html = mime_type == MimeType::TextHtml;
345+
341346
if is_html {
342347
PartType::Html(text)
343348
} else {

0 commit comments

Comments
 (0)