diff --git a/resources/eml/legacy/030.crlf.json b/resources/eml/legacy/030.crlf.json index f970930..e21c89e 100644 --- a/resources/eml/legacy/030.crlf.json +++ b/resources/eml/legacy/030.crlf.json @@ -10,8 +10,6 @@ 3 ], "attachments": [ - 2, - 3, 4 ], "parts": [ diff --git a/resources/eml/legacy/030.json b/resources/eml/legacy/030.json index f970930..e21c89e 100644 --- a/resources/eml/legacy/030.json +++ b/resources/eml/legacy/030.json @@ -10,8 +10,6 @@ 3 ], "attachments": [ - 2, - 3, 4 ], "parts": [ diff --git a/resources/eml/legacy/032.crlf.json b/resources/eml/legacy/032.crlf.json index 1d711ca..77e2317 100644 --- a/resources/eml/legacy/032.crlf.json +++ b/resources/eml/legacy/032.crlf.json @@ -9,10 +9,7 @@ 4, 5 ], - "attachments": [ - 4, - 5 - ], + "attachments": [], "parts": [ { "headers": [ diff --git a/resources/eml/legacy/032.json b/resources/eml/legacy/032.json index 1d711ca..77e2317 100644 --- a/resources/eml/legacy/032.json +++ b/resources/eml/legacy/032.json @@ -9,10 +9,7 @@ 4, 5 ], - "attachments": [ - 4, - 5 - ], + "attachments": [], "parts": [ { "headers": [ diff --git a/resources/eml/legacy/035.crlf.json b/resources/eml/legacy/035.crlf.json index 02ee5a4..b969417 100644 --- a/resources/eml/legacy/035.crlf.json +++ b/resources/eml/legacy/035.crlf.json @@ -11,9 +11,7 @@ ], "attachments": [ 5, - 6, - 7, - 8 + 6 ], "parts": [ { diff --git a/resources/eml/legacy/035.json b/resources/eml/legacy/035.json index 02ee5a4..b969417 100644 --- a/resources/eml/legacy/035.json +++ b/resources/eml/legacy/035.json @@ -11,9 +11,7 @@ ], "attachments": [ 5, - 6, - 7, - 8 + 6 ], "parts": [ { diff --git a/resources/eml/legacy/037.crlf.json b/resources/eml/legacy/037.crlf.json index eb1621e..b419745 100644 --- a/resources/eml/legacy/037.crlf.json +++ b/resources/eml/legacy/037.crlf.json @@ -7,9 +7,7 @@ 1, 2 ], - "attachments": [ - 2 - ], + "attachments": [], "parts": [ { "headers": [ diff --git a/resources/eml/legacy/037.json b/resources/eml/legacy/037.json index eb1621e..b419745 100644 --- a/resources/eml/legacy/037.json +++ b/resources/eml/legacy/037.json @@ -7,9 +7,7 @@ 1, 2 ], - "attachments": [ - 2 - ], + "attachments": [], "parts": [ { "headers": [ diff --git a/resources/eml/legacy/039.crlf.json b/resources/eml/legacy/039.crlf.json index f676322..3fe2fec 100644 --- a/resources/eml/legacy/039.crlf.json +++ b/resources/eml/legacy/039.crlf.json @@ -11,9 +11,7 @@ ], "attachments": [ 3, - 4, - 5, - 6 + 4 ], "parts": [ { diff --git a/resources/eml/legacy/039.json b/resources/eml/legacy/039.json index f676322..3fe2fec 100644 --- a/resources/eml/legacy/039.json +++ b/resources/eml/legacy/039.json @@ -11,9 +11,7 @@ ], "attachments": [ 3, - 4, - 5, - 6 + 4 ], "parts": [ { diff --git a/resources/eml/legacy/044.crlf.json b/resources/eml/legacy/044.crlf.json index db7a51a..96aa97d 100644 --- a/resources/eml/legacy/044.crlf.json +++ b/resources/eml/legacy/044.crlf.json @@ -11,11 +11,7 @@ 3, 4 ], - "attachments": [ - 2, - 3, - 4 - ], + "attachments": [], "parts": [ { "headers": [ diff --git a/resources/eml/legacy/044.json b/resources/eml/legacy/044.json index db7a51a..96aa97d 100644 --- a/resources/eml/legacy/044.json +++ b/resources/eml/legacy/044.json @@ -11,11 +11,7 @@ 3, 4 ], - "attachments": [ - 2, - 3, - 4 - ], + "attachments": [], "parts": [ { "headers": [ diff --git a/resources/eml/legacy/048.crlf.json b/resources/eml/legacy/048.crlf.json index ba2979a..1312d53 100644 --- a/resources/eml/legacy/048.crlf.json +++ b/resources/eml/legacy/048.crlf.json @@ -11,11 +11,7 @@ 3, 4 ], - "attachments": [ - 2, - 3, - 4 - ], + "attachments": [], "parts": [ { "headers": [ diff --git a/resources/eml/legacy/048.json b/resources/eml/legacy/048.json index ba2979a..1312d53 100644 --- a/resources/eml/legacy/048.json +++ b/resources/eml/legacy/048.json @@ -11,11 +11,7 @@ 3, 4 ], - "attachments": [ - 2, - 3, - 4 - ], + "attachments": [], "parts": [ { "headers": [ diff --git a/resources/eml/malformed/017.crlf.json b/resources/eml/malformed/017.crlf.json index 4972aa8..e0c772f 100644 --- a/resources/eml/malformed/017.crlf.json +++ b/resources/eml/malformed/017.crlf.json @@ -5,9 +5,7 @@ "text_body": [ 1 ], - "attachments": [ - 1 - ], + "attachments": [], "parts": [ { "headers": [ diff --git a/resources/eml/malformed/017.json b/resources/eml/malformed/017.json index f90de12..8a0213e 100644 --- a/resources/eml/malformed/017.json +++ b/resources/eml/malformed/017.json @@ -5,9 +5,7 @@ "text_body": [ 1 ], - "attachments": [ - 1 - ], + "attachments": [], "parts": [ { "headers": [ diff --git a/resources/eml/rfc/002.crlf.json b/resources/eml/rfc/002.crlf.json index 14934d2..86b6775 100644 --- a/resources/eml/rfc/002.crlf.json +++ b/resources/eml/rfc/002.crlf.json @@ -169,9 +169,7 @@ 1, 2 ], - "attachments": [ - 2 - ], + "attachments": [], "parts": [ { "headers": [ diff --git a/resources/eml/rfc/002.json b/resources/eml/rfc/002.json index 7911439..f138207 100644 --- a/resources/eml/rfc/002.json +++ b/resources/eml/rfc/002.json @@ -169,9 +169,7 @@ 1, 2 ], - "attachments": [ - 2 - ], + "attachments": [], "parts": [ { "headers": [ diff --git a/resources/eml/thirdparty/013.crlf.json b/resources/eml/thirdparty/013.crlf.json index 969ba42..91dc460 100644 --- a/resources/eml/thirdparty/013.crlf.json +++ b/resources/eml/thirdparty/013.crlf.json @@ -11,11 +11,7 @@ 5, 6 ], - "attachments": [ - 4, - 5, - 6 - ], + "attachments": [], "parts": [ { "headers": [ diff --git a/resources/eml/thirdparty/013.json b/resources/eml/thirdparty/013.json index ceebf9e..badd433 100644 --- a/resources/eml/thirdparty/013.json +++ b/resources/eml/thirdparty/013.json @@ -11,11 +11,7 @@ 5, 6 ], - "attachments": [ - 4, - 5, - 6 - ], + "attachments": [], "parts": [ { "headers": [ diff --git a/src/parsers/message.rs b/src/parsers/message.rs index 926edd9..ea29126 100644 --- a/src/parsers/message.rs +++ b/src/parsers/message.rs @@ -314,6 +314,13 @@ impl MessageParser { message.text_body.push(message.parts.len()); } + if !is_multipart && !add_to_text && !add_to_html + || (is_multipart || mime_type == MimeType::Inline) + && (!add_to_text || !add_to_html) + { + message.attachments.push(message.parts.len()); + } + if is_text { let text = match ( bytes, @@ -332,25 +339,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 { + if mime_type == MimeType::TextHtml { PartType::Html(text) } else { PartType::Text(text) } + } else if is_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());