diff --git a/resources/eml/legacy/015.crlf.json b/resources/eml/legacy/015.crlf.json index ccf865d..6737c56 100644 --- a/resources/eml/legacy/015.crlf.json +++ b/resources/eml/legacy/015.crlf.json @@ -360,7 +360,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1751,7 +1751,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/015.json b/resources/eml/legacy/015.json index ccf865d..6737c56 100644 --- a/resources/eml/legacy/015.json +++ b/resources/eml/legacy/015.json @@ -360,7 +360,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1751,7 +1751,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/018.crlf.json b/resources/eml/legacy/018.crlf.json index 1a81b42..da36f88 100644 --- a/resources/eml/legacy/018.crlf.json +++ b/resources/eml/legacy/018.crlf.json @@ -325,7 +325,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1716,7 +1716,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/018.json b/resources/eml/legacy/018.json index 1a81b42..da36f88 100644 --- a/resources/eml/legacy/018.json +++ b/resources/eml/legacy/018.json @@ -325,7 +325,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1716,7 +1716,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/024.crlf.json b/resources/eml/legacy/024.crlf.json index 58eab6b..33cf248 100644 --- a/resources/eml/legacy/024.crlf.json +++ b/resources/eml/legacy/024.crlf.json @@ -255,7 +255,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1646,7 +1646,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/024.json b/resources/eml/legacy/024.json index 58eab6b..33cf248 100644 --- a/resources/eml/legacy/024.json +++ b/resources/eml/legacy/024.json @@ -255,7 +255,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1646,7 +1646,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/025.crlf.json b/resources/eml/legacy/025.crlf.json index 2d76d28..be63cbc 100644 --- a/resources/eml/legacy/025.crlf.json +++ b/resources/eml/legacy/025.crlf.json @@ -290,7 +290,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1681,7 +1681,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/025.json b/resources/eml/legacy/025.json index 2d76d28..be63cbc 100644 --- a/resources/eml/legacy/025.json +++ b/resources/eml/legacy/025.json @@ -290,7 +290,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1681,7 +1681,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/035.crlf.json b/resources/eml/legacy/035.crlf.json index 02ee5a4..9a81e47 100644 --- a/resources/eml/legacy/035.crlf.json +++ b/resources/eml/legacy/035.crlf.json @@ -344,7 +344,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1730,7 +1730,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/035.json b/resources/eml/legacy/035.json index 02ee5a4..9a81e47 100644 --- a/resources/eml/legacy/035.json +++ b/resources/eml/legacy/035.json @@ -344,7 +344,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1730,7 +1730,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/039.crlf.json b/resources/eml/legacy/039.crlf.json index f676322..57fb0d3 100644 --- a/resources/eml/legacy/039.crlf.json +++ b/resources/eml/legacy/039.crlf.json @@ -274,7 +274,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1660,7 +1660,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/039.json b/resources/eml/legacy/039.json index f676322..57fb0d3 100644 --- a/resources/eml/legacy/039.json +++ b/resources/eml/legacy/039.json @@ -274,7 +274,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1660,7 +1660,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/050.crlf.json b/resources/eml/legacy/050.crlf.json index ad2d7d1..b7acd92 100644 --- a/resources/eml/legacy/050.crlf.json +++ b/resources/eml/legacy/050.crlf.json @@ -255,7 +255,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1646,7 +1646,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/050.json b/resources/eml/legacy/050.json index ad2d7d1..b7acd92 100644 --- a/resources/eml/legacy/050.json +++ b/resources/eml/legacy/050.json @@ -255,7 +255,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1646,7 +1646,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/051.crlf.json b/resources/eml/legacy/051.crlf.json index 308013f..aba3025 100644 --- a/resources/eml/legacy/051.crlf.json +++ b/resources/eml/legacy/051.crlf.json @@ -290,7 +290,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1681,7 +1681,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/legacy/051.json b/resources/eml/legacy/051.json index 308013f..aba3025 100644 --- a/resources/eml/legacy/051.json +++ b/resources/eml/legacy/051.json @@ -290,7 +290,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, @@ -1681,7 +1681,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/thirdparty/011.crlf.json b/resources/eml/thirdparty/011.crlf.json index bfb1da9..e6ee9c5 100644 --- a/resources/eml/thirdparty/011.crlf.json +++ b/resources/eml/thirdparty/011.crlf.json @@ -367,7 +367,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/resources/eml/thirdparty/011.json b/resources/eml/thirdparty/011.json index b81bd6c..de55e3e 100644 --- a/resources/eml/thirdparty/011.json +++ b/resources/eml/thirdparty/011.json @@ -367,7 +367,7 @@ ], "is_encoding_problem": false, "body": { - "Binary": [ + "InlineBinary": [ 137, 80, 78, diff --git a/src/parsers/message.rs b/src/parsers/message.rs index 926edd9..12ff9db 100644 --- a/src/parsers/message.rs +++ b/src/parsers/message.rs @@ -264,6 +264,14 @@ impl MessageParser { } let body_part = if mime_type != MimeType::Message { + let additional_inline = mime_type == MimeType::Inline + && part_headers + .header_value(&HeaderName::ContentDisposition) + .map_or(false, |d| { + d.as_content_type().is_some_and(|ct| ct.is_inline()) + }) + && state.mime_type == MimeType::MultipartRelated; + let is_inline = is_inline && part_headers .header_value(&HeaderName::ContentDisposition) @@ -314,6 +322,12 @@ impl MessageParser { message.text_body.push(message.parts.len()); } + let is_html = mime_type == MimeType::TextHtml; + + if !is_text || !add_to_html && is_html || !add_to_text && !is_html { + message.attachments.push(message.parts.len()); + } + if is_text { let text = match ( bytes, @@ -332,25 +346,15 @@ impl MessageParser { (Cow::Borrowed(bytes), None) => String::from_utf8_lossy(bytes), }; - let is_html = mime_type == MimeType::TextHtml; - - if !add_to_html && is_html || !add_to_text && !is_html { - message.attachments.push(message.parts.len()); - } - if is_html { PartType::Html(text) } else { PartType::Text(text) } + } else if is_inline || additional_inline { + PartType::InlineBinary(bytes) } else { - message.attachments.push(message.parts.len()); - - if !is_inline { - PartType::Binary(bytes) - } else { - PartType::InlineBinary(bytes) - } + PartType::Binary(bytes) } } else { message.attachments.push(message.parts.len());