diff --git a/Cargo.lock b/Cargo.lock index 4940477..8e91c18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "android_system_properties" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7ed72e1635e121ca3e79420540282af22da58be50de153d36f81ddc6b83aa9e" +dependencies = [ + "libc", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -17,6 +26,12 @@ dependencies = [ "serde", ] +[[package]] +name = "bumpalo" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" + [[package]] name = "cfg-if" version = "1.0.0" @@ -25,17 +40,25 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" dependencies = [ - "libc", + "iana-time-zone", + "js-sys", "num-integer", "num-traits", "time", + "wasm-bindgen", "winapi", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + [[package]] name = "encoding_rs" version = "0.8.31" @@ -47,15 +70,28 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.11.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "iana-time-zone" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad2bfd338099682614d3ee3fe0cd72e0b6a41ca6a87f6a74a3bd593c91650501" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "js-sys", + "wasm-bindgen", + "winapi", +] [[package]] name = "indexmap" -version = "1.8.2" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", "hashbrown", @@ -63,21 +99,33 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" +checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" + +[[package]] +name = "js-sys" +version = "0.3.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" +dependencies = [ + "wasm-bindgen", +] [[package]] name = "libc" -version = "0.2.126" +version = "0.2.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" [[package]] -name = "linked-hash-map" -version = "0.5.4" +name = "log" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] [[package]] name = "mail-parser" @@ -111,43 +159,49 @@ dependencies = [ ] [[package]] -name = "proc-macro2" -version = "1.0.39" +name = "once_cell" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e" + +[[package]] +name = "proc-macro2" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.18" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] [[package]] name = "ryu" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] name = "serde" -version = "1.0.137" +version = "1.0.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00" dependencies = [ "proc-macro2", "quote", @@ -156,9 +210,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.81" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7" dependencies = [ "itoa", "ryu", @@ -167,21 +221,22 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.8.24" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707d15895415db6628332b737c838b88c598522e4dc70647e59b72312924aebc" +checksum = "f50845f68d5c693aac7d72a25415ddd21cb8182c04eafe447b73af55a05f9e1b" dependencies = [ "indexmap", + "itoa", "ryu", "serde", - "yaml-rust", + "unsafe-libyaml", ] [[package]] name = "syn" -version = "1.0.96" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf" +checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" dependencies = [ "proc-macro2", "quote", @@ -201,9 +256,15 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" +checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" + +[[package]] +name = "unsafe-libyaml" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "931179334a56395bcf64ba5e0ff56781381c1a5832178280c7d7f91d1679aeb0" [[package]] name = "wasi" @@ -211,6 +272,60 @@ version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +[[package]] +name = "wasm-bindgen" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" + [[package]] name = "winapi" version = "0.3.9" @@ -232,12 +347,3 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] diff --git a/Cargo.toml b/Cargo.toml index 882832c..16d17f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ encoding_rs = {version="0.8", optional=true} serde = { version = "1.0", features = ["derive"], optional=true} [dev-dependencies] -serde_yaml = "0.8" +serde_yaml = "0.9.9" serde_json = "1.0" bincode = "1.3.3" chrono = "0.4" diff --git a/src/parsers/header.rs b/src/parsers/header.rs index 112c0ea..f84d244 100644 --- a/src/parsers/header.rs +++ b/src/parsers/header.rs @@ -26,7 +26,7 @@ use super::{ message::MessageStream, }; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum HeaderParserResult<'x> { Rfc(RfcHeader), Other(Cow<'x, str>), diff --git a/src/parsers/message.rs b/src/parsers/message.rs index b90f63c..a83c7c9 100644 --- a/src/parsers/message.rs +++ b/src/parsers/message.rs @@ -503,7 +503,16 @@ impl<'x> Message<'x> { let offset_end = state .mime_boundary .as_ref() - .map(|b| stream.pos.saturating_sub(b.len())) + .map(|b| { + let pos = stream.pos.saturating_sub(b.len()); + stream.data.get(pos - 2).map_or(pos - 1, |&ch| { + if ch == b'\r' { + pos - 2 + } else { + pos - 1 + } + }) + }) .unwrap_or(stream.pos); message.raw_message = raw_message[state.offset_header..offset_end].as_ref().into(); @@ -610,6 +619,7 @@ impl<'x> Message<'x> { message.raw_message = raw_message.into(); if !message.is_empty() { + message.parts[0].offset_end = message.raw_message.len(); Some(message) } else { None diff --git a/src/parsers/mime.rs b/src/parsers/mime.rs index 39e5956..76afeb6 100644 --- a/src/parsers/mime.rs +++ b/src/parsers/mime.rs @@ -13,7 +13,7 @@ use crate::decoders::DecodeResult; use super::message::MessageStream; -pub fn seek_next_part(stream: &mut MessageStream, boundary: &[u8]) -> bool { +pub(crate) fn seek_next_part(stream: &mut MessageStream, boundary: &[u8]) -> bool { if !boundary.is_empty() { let mut pos = stream.pos; @@ -44,7 +44,7 @@ pub fn seek_next_part(stream: &mut MessageStream, boundary: &[u8]) -> bool { false } -pub fn get_bytes_to_boundary<'x>( +pub(crate) fn get_bytes_to_boundary<'x>( stream: &MessageStream<'x>, start_pos: usize, boundary: &[u8], @@ -115,14 +115,14 @@ pub fn get_bytes_to_boundary<'x>( } #[inline(always)] -pub fn is_boundary_end(stream: &MessageStream, pos: usize) -> bool { +pub(crate) fn is_boundary_end(stream: &MessageStream, pos: usize) -> bool { matches!( stream.data.get(pos..), Some([b'\n' | b'\r' | b' ' | b'\t', ..]) | Some([b'-', b'-', ..]) | Some([]) | None ) } -pub fn skip_multipart_end(stream: &mut MessageStream) -> bool { +pub(crate) fn skip_multipart_end(stream: &mut MessageStream) -> bool { match stream.data.get(stream.pos..stream.pos + 2) { Some(b"--") => { if let Some(byte) = stream.data.get(stream.pos + 2) { @@ -138,7 +138,7 @@ pub fn skip_multipart_end(stream: &mut MessageStream) -> bool { } #[inline(always)] -pub fn skip_crlf(stream: &mut MessageStream) { +pub(crate) fn skip_crlf(stream: &mut MessageStream) { for ch in &stream.data[stream.pos..] { match ch { b'\r' | b' ' | b'\t' => stream.pos += 1, @@ -152,19 +152,7 @@ pub fn skip_crlf(stream: &mut MessageStream) { } #[inline(always)] -pub fn seek_crlf_end(stream: &MessageStream, mut start_pos: usize) -> usize { - for ch in &stream.data[start_pos..] { - if ch.is_ascii_whitespace() { - start_pos += 1; - } else { - break; - } - } - start_pos -} - -#[inline(always)] -pub fn seek_crlf(stream: &MessageStream, mut start_pos: usize) -> usize { +pub(crate) fn seek_crlf(stream: &MessageStream, mut start_pos: usize) -> usize { for ch in &stream.data[start_pos..] { match ch { b'\r' | b' ' | b'\t' => start_pos += 1, diff --git a/tests/legacy/003.json b/tests/legacy/003.json index e02242d..1162b04 100644 --- a/tests/legacy/003.json +++ b/tests/legacy/003.json @@ -144,7 +144,7 @@ }, "offset_header": 0, "offset_body": 498, - "offset_end": 2625 + "offset_end": 2627 }, { "headers": [ diff --git a/tests/legacy/015.json b/tests/legacy/015.json index effbff2..6f6202b 100644 --- a/tests/legacy/015.json +++ b/tests/legacy/015.json @@ -150,7 +150,7 @@ }, "offset_header": 0, "offset_body": 484, - "offset_end": 11500 + "offset_end": 11502 }, { "headers": [ diff --git a/tests/legacy/016.json b/tests/legacy/016.json index 2d01096..db67503 100644 --- a/tests/legacy/016.json +++ b/tests/legacy/016.json @@ -138,7 +138,7 @@ }, "offset_header": 0, "offset_body": 491, - "offset_end": 4871 + "offset_end": 4873 }, { "headers": [ diff --git a/tests/legacy/017.json b/tests/legacy/017.json index 83cdd3b..b6a5075 100644 --- a/tests/legacy/017.json +++ b/tests/legacy/017.json @@ -138,7 +138,7 @@ }, "offset_header": 0, "offset_body": 436, - "offset_end": 5446 + "offset_end": 5448 }, { "headers": [ diff --git a/tests/legacy/018.json b/tests/legacy/018.json index ff5def0..c9ede68 100644 --- a/tests/legacy/018.json +++ b/tests/legacy/018.json @@ -152,7 +152,7 @@ }, "offset_header": 0, "offset_body": 522, - "offset_end": 7393 + "offset_end": 7395 }, { "headers": [ diff --git a/tests/legacy/023.json b/tests/legacy/023.json index 820d3f0..cc0faca 100644 --- a/tests/legacy/023.json +++ b/tests/legacy/023.json @@ -140,7 +140,7 @@ }, "offset_header": 0, "offset_body": 491, - "offset_end": 5435 + "offset_end": 5437 }, { "headers": [ diff --git a/tests/legacy/024.json b/tests/legacy/024.json index 81e82e2..9eb53de 100644 --- a/tests/legacy/024.json +++ b/tests/legacy/024.json @@ -152,7 +152,7 @@ }, "offset_header": 0, "offset_body": 510, - "offset_end": 6229 + "offset_end": 6231 }, { "headers": [ diff --git a/tests/legacy/025.json b/tests/legacy/025.json index cf754fa..478b1b8 100644 --- a/tests/legacy/025.json +++ b/tests/legacy/025.json @@ -150,7 +150,7 @@ }, "offset_header": 0, "offset_body": 484, - "offset_end": 10336 + "offset_end": 10338 }, { "headers": [ diff --git a/tests/legacy/026.json b/tests/legacy/026.json index b63c602..9fd324c 100644 --- a/tests/legacy/026.json +++ b/tests/legacy/026.json @@ -138,7 +138,7 @@ }, "offset_header": 0, "offset_body": 462, - "offset_end": 3741 + "offset_end": 3743 }, { "headers": [ diff --git a/tests/legacy/030.json b/tests/legacy/030.json index 571a0ab..944b99a 100644 --- a/tests/legacy/030.json +++ b/tests/legacy/030.json @@ -144,7 +144,7 @@ }, "offset_header": 0, "offset_body": 378, - "offset_end": 6292 + "offset_end": 6294 }, { "headers": [ diff --git a/tests/legacy/032.json b/tests/legacy/032.json index 94335dc..abd83e5 100644 --- a/tests/legacy/032.json +++ b/tests/legacy/032.json @@ -142,7 +142,7 @@ }, "offset_header": 0, "offset_body": 378, - "offset_end": 6608 + "offset_end": 6610 }, { "headers": [ diff --git a/tests/legacy/035.json b/tests/legacy/035.json index 4ca3efe..a391589 100644 --- a/tests/legacy/035.json +++ b/tests/legacy/035.json @@ -144,7 +144,7 @@ }, "offset_header": 0, "offset_body": 430, - "offset_end": 11447 + "offset_end": 11449 }, { "headers": [ diff --git a/tests/legacy/037.json b/tests/legacy/037.json index 1da3c54..e2869c9 100644 --- a/tests/legacy/037.json +++ b/tests/legacy/037.json @@ -138,7 +138,7 @@ }, "offset_header": 0, "offset_body": 378, - "offset_end": 2587 + "offset_end": 2589 }, { "headers": [ diff --git a/tests/legacy/039.json b/tests/legacy/039.json index b2f6356..5938066 100644 --- a/tests/legacy/039.json +++ b/tests/legacy/039.json @@ -144,7 +144,7 @@ }, "offset_header": 0, "offset_body": 415, - "offset_end": 10135 + "offset_end": 10137 }, { "headers": [ diff --git a/tests/legacy/042.json b/tests/legacy/042.json index 3d0fe19..ed543ae 100644 --- a/tests/legacy/042.json +++ b/tests/legacy/042.json @@ -136,7 +136,7 @@ }, "offset_header": 0, "offset_body": 378, - "offset_end": 2370 + "offset_end": 2372 }, { "headers": [ diff --git a/tests/legacy/047.json b/tests/legacy/047.json index 1336dff..2f38a18 100644 --- a/tests/legacy/047.json +++ b/tests/legacy/047.json @@ -136,7 +136,7 @@ }, "offset_header": 0, "offset_body": 378, - "offset_end": 2436 + "offset_end": 2438 }, { "headers": [ diff --git a/tests/legacy/048.json b/tests/legacy/048.json index 9af9cbc..36631d4 100644 --- a/tests/legacy/048.json +++ b/tests/legacy/048.json @@ -146,7 +146,7 @@ }, "offset_header": 0, "offset_body": 378, - "offset_end": 7718 + "offset_end": 7720 }, { "headers": [ diff --git a/tests/legacy/050.json b/tests/legacy/050.json index 2ee43a4..2b6db82 100644 --- a/tests/legacy/050.json +++ b/tests/legacy/050.json @@ -152,7 +152,7 @@ }, "offset_header": 0, "offset_body": 510, - "offset_end": 6229 + "offset_end": 6231 }, { "headers": [ diff --git a/tests/legacy/051.json b/tests/legacy/051.json index dbe9f29..99b5c71 100644 --- a/tests/legacy/051.json +++ b/tests/legacy/051.json @@ -150,7 +150,7 @@ }, "offset_header": 0, "offset_body": 484, - "offset_end": 9941 + "offset_end": 9943 }, { "headers": [ diff --git a/tests/malformed/012.json b/tests/malformed/012.json index 780d7e8..5395296 100644 --- a/tests/malformed/012.json +++ b/tests/malformed/012.json @@ -129,7 +129,7 @@ }, "offset_header": 98, "offset_body": 128, - "offset_end": 156 + "offset_end": 155 }, { "headers": [ diff --git a/tests/malformed/015.json b/tests/malformed/015.json index 9c620f1..1dccdb5 100644 --- a/tests/malformed/015.json +++ b/tests/malformed/015.json @@ -134,7 +134,7 @@ }, "offset_header": 0, "offset_body": 335, - "offset_end": 586 + "offset_end": 587 }, { "headers": [ diff --git a/tests/rfc/000.json b/tests/rfc/000.json index d0e8705..e5991e3 100644 --- a/tests/rfc/000.json +++ b/tests/rfc/000.json @@ -393,7 +393,7 @@ }, "offset_header": 1577, "offset_body": 1607, - "offset_end": 1831 + "offset_end": 1830 } ] } \ No newline at end of file diff --git a/tests/rfc/001.json b/tests/rfc/001.json index 5c58ef7..b68d402 100644 --- a/tests/rfc/001.json +++ b/tests/rfc/001.json @@ -113,7 +113,7 @@ }, "offset_header": 0, "offset_body": 198, - "offset_end": 1107 + "offset_end": 1108 }, { "headers": [ diff --git a/tests/rfc/002.json b/tests/rfc/002.json index abb2231..9f24bc3 100644 --- a/tests/rfc/002.json +++ b/tests/rfc/002.json @@ -706,7 +706,7 @@ }, "offset_header": 537, "offset_body": 627, - "offset_end": 2607 + "offset_end": 2606 } ] } \ No newline at end of file diff --git a/tests/rfc/004.json b/tests/rfc/004.json index a800f4b..d0542ba 100644 --- a/tests/rfc/004.json +++ b/tests/rfc/004.json @@ -224,7 +224,7 @@ }, "offset_header": 417, "offset_body": 418, - "offset_end": 519 + "offset_end": 518 }, { "headers": [], @@ -298,7 +298,7 @@ }, "offset_header": 544, "offset_body": 545, - "offset_end": 671 + "offset_end": 670 } ] } \ No newline at end of file diff --git a/tests/rfc/005.json b/tests/rfc/005.json index 59d25d9..9001f39 100644 --- a/tests/rfc/005.json +++ b/tests/rfc/005.json @@ -106,7 +106,7 @@ }, "offset_header": 0, "offset_body": 224, - "offset_end": 640 + "offset_end": 690 }, { "headers": [], diff --git a/tests/rfc/007.json b/tests/rfc/007.json index 2b06058..93ba3e1 100644 --- a/tests/rfc/007.json +++ b/tests/rfc/007.json @@ -530,7 +530,7 @@ }, "offset_header": 751, "offset_body": 781, - "offset_end": 795 + "offset_end": 794 }, { "headers": [ diff --git a/tests/thirdparty/007.json b/tests/thirdparty/007.json index d54e9a5..8c960d2 100644 --- a/tests/thirdparty/007.json +++ b/tests/thirdparty/007.json @@ -106,7 +106,7 @@ }, "offset_header": 86, "offset_body": 87, - "offset_end": 161 + "offset_end": 160 }, { "headers": [], @@ -160,7 +160,7 @@ }, "offset_header": 165, "offset_body": 166, - "offset_end": 241 + "offset_end": 240 }, { "headers": [], @@ -324,7 +324,7 @@ }, "offset_header": 245, "offset_body": 246, - "offset_end": 565 + "offset_end": 564 } ] } \ No newline at end of file diff --git a/tests/thirdparty/008.json b/tests/thirdparty/008.json index f46345d..0235820 100644 --- a/tests/thirdparty/008.json +++ b/tests/thirdparty/008.json @@ -95,7 +95,7 @@ }, "offset_header": 0, "offset_body": 172, - "offset_end": 790 + "offset_end": 810 }, { "headers": [ @@ -360,7 +360,7 @@ }, "offset_header": 265, "offset_body": 295, - "offset_end": 729 + "offset_end": 728 }, { "headers": [ diff --git a/tests/thirdparty/012.json b/tests/thirdparty/012.json index b1b0ae0..82681a2 100644 --- a/tests/thirdparty/012.json +++ b/tests/thirdparty/012.json @@ -90,7 +90,7 @@ }, "offset_header": 0, "offset_body": 173, - "offset_end": 589 + "offset_end": 607 }, { "headers": [ @@ -281,7 +281,7 @@ }, "offset_header": 266, "offset_body": 296, - "offset_end": 577 + "offset_end": 576 } ] } \ No newline at end of file diff --git a/tests/thirdparty/013.eml b/tests/thirdparty/013.eml new file mode 100644 index 0000000..328a8f5 --- /dev/null +++ b/tests/thirdparty/013.eml @@ -0,0 +1,46 @@ +Date: Fri, 19 Aug 2022 13:10:40 +0000 +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary=166091464015.94FEC6.541095 +Content-Transfer-Encoding: 7bit + + +--166091464015.94FEC6.541095 +Date: Fri, 19 Aug 2022 13:10:40 +0000 +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary=166091464014.8cee04D8.541095 +Content-Transfer-Encoding: 7bit + + +--166091464014.8cee04D8.541095 +Date: Fri, 19 Aug 2022 13:10:40 +0000 +MIME-Version: 1.0 +Content-Type: text/plain + +a +--166091464014.8cee04D8.541095 +Date: Fri, 19 Aug 2022 13:10:40 +0000 +MIME-Version: 1.0 +Content-Type: text/html + +b +--166091464014.8cee04D8.541095-- + +--166091464015.94FEC6.541095 +Date: Fri, 19 Aug 2022 13:10:40 +0000 +MIME-Version: 1.0 +Content-Type: image/jpeg + +c +--166091464015.94FEC6.541095 +Date: Fri, 19 Aug 2022 13:10:40 +0000 +MIME-Version: 1.0 +Content-Type: audio/mp3 + +d +--166091464015.94FEC6.541095 +Date: Fri, 19 Aug 2022 13:10:40 +0000 +MIME-Version: 1.0 +Content-Type: video/avi + +e +--166091464015.94FEC6.541095-- diff --git a/tests/thirdparty/013.json b/tests/thirdparty/013.json new file mode 100644 index 0000000..df8a910 --- /dev/null +++ b/tests/thirdparty/013.json @@ -0,0 +1,450 @@ +{ + "html_body": [ + 3, + 4, + 5, + 6 + ], + "text_body": [ + 2, + 4, + 5, + 6 + ], + "attachments": [ + 4, + 5, + 6 + ], + "parts": [ + { + "headers": [ + { + "name": { + "Rfc": "date" + }, + "value": { + "DateTime": { + "year": 2022, + "month": 8, + "day": 19, + "hour": 13, + "minute": 10, + "second": 40, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + }, + "offset_start": 5, + "offset_end": 38 + }, + { + "name": { + "Rfc": "mime_version" + }, + "value": { + "Text": "1.0" + }, + "offset_start": 51, + "offset_end": 56 + }, + { + "name": { + "Rfc": "content_type" + }, + "value": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": [ + [ + "boundary", + "166091464015.94FEC6.541095" + ] + ] + } + }, + "offset_start": 69, + "offset_end": 123 + }, + { + "name": { + "Rfc": "content_transfer_encoding" + }, + "value": { + "Text": "7bit" + }, + "offset_start": 149, + "offset_end": 155 + } + ], + "is_encoding_problem": false, + "body": { + "Multipart": [ + 1, + 4, + 5, + 6 + ] + }, + "offset_header": 0, + "offset_body": 156, + "offset_end": 982 + }, + { + "headers": [ + { + "name": { + "Rfc": "date" + }, + "value": { + "DateTime": { + "year": 2022, + "month": 8, + "day": 19, + "hour": 13, + "minute": 10, + "second": 40, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + }, + "offset_start": 191, + "offset_end": 224 + }, + { + "name": { + "Rfc": "mime_version" + }, + "value": { + "Text": "1.0" + }, + "offset_start": 237, + "offset_end": 242 + }, + { + "name": { + "Rfc": "content_type" + }, + "value": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "alternative", + "attributes": [ + [ + "boundary", + "166091464014.8cee04D8.541095" + ] + ] + } + }, + "offset_start": 255, + "offset_end": 317 + }, + { + "name": { + "Rfc": "content_transfer_encoding" + }, + "value": { + "Text": "7bit" + }, + "offset_start": 343, + "offset_end": 349 + } + ], + "is_encoding_problem": false, + "body": { + "Multipart": [ + 2, + 3 + ] + }, + "offset_header": 186, + "offset_body": 350, + "offset_end": 613 + }, + { + "headers": [ + { + "name": { + "Rfc": "date" + }, + "value": { + "DateTime": { + "year": 2022, + "month": 8, + "day": 19, + "hour": 13, + "minute": 10, + "second": 40, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + }, + "offset_start": 387, + "offset_end": 420 + }, + { + "name": { + "Rfc": "mime_version" + }, + "value": { + "Text": "1.0" + }, + "offset_start": 433, + "offset_end": 438 + }, + { + "name": { + "Rfc": "content_type" + }, + "value": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": null + } + }, + "offset_start": 451, + "offset_end": 463 + } + ], + "is_encoding_problem": false, + "body": { + "Text": "a" + }, + "offset_header": 382, + "offset_body": 464, + "offset_end": 465 + }, + { + "headers": [ + { + "name": { + "Rfc": "date" + }, + "value": { + "DateTime": { + "year": 2022, + "month": 8, + "day": 19, + "hour": 13, + "minute": 10, + "second": 40, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + }, + "offset_start": 502, + "offset_end": 535 + }, + { + "name": { + "Rfc": "mime_version" + }, + "value": { + "Text": "1.0" + }, + "offset_start": 548, + "offset_end": 553 + }, + { + "name": { + "Rfc": "content_type" + }, + "value": { + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": null + } + }, + "offset_start": 566, + "offset_end": 577 + } + ], + "is_encoding_problem": false, + "body": { + "Html": "b" + }, + "offset_header": 497, + "offset_body": 578, + "offset_end": 579 + }, + { + "headers": [ + { + "name": { + "Rfc": "date" + }, + "value": { + "DateTime": { + "year": 2022, + "month": 8, + "day": 19, + "hour": 13, + "minute": 10, + "second": 40, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + }, + "offset_start": 648, + "offset_end": 681 + }, + { + "name": { + "Rfc": "mime_version" + }, + "value": { + "Text": "1.0" + }, + "offset_start": 694, + "offset_end": 699 + }, + { + "name": { + "Rfc": "content_type" + }, + "value": { + "ContentType": { + "c_type": "image", + "c_subtype": "jpeg", + "attributes": null + } + }, + "offset_start": 712, + "offset_end": 724 + } + ], + "is_encoding_problem": false, + "body": { + "InlineBinary": [ + 99 + ] + }, + "offset_header": 643, + "offset_body": 725, + "offset_end": 726 + }, + { + "headers": [ + { + "name": { + "Rfc": "date" + }, + "value": { + "DateTime": { + "year": 2022, + "month": 8, + "day": 19, + "hour": 13, + "minute": 10, + "second": 40, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + }, + "offset_start": 761, + "offset_end": 794 + }, + { + "name": { + "Rfc": "mime_version" + }, + "value": { + "Text": "1.0" + }, + "offset_start": 807, + "offset_end": 812 + }, + { + "name": { + "Rfc": "content_type" + }, + "value": { + "ContentType": { + "c_type": "audio", + "c_subtype": "mp3", + "attributes": null + } + }, + "offset_start": 825, + "offset_end": 836 + } + ], + "is_encoding_problem": false, + "body": { + "InlineBinary": [ + 100 + ] + }, + "offset_header": 756, + "offset_body": 837, + "offset_end": 838 + }, + { + "headers": [ + { + "name": { + "Rfc": "date" + }, + "value": { + "DateTime": { + "year": 2022, + "month": 8, + "day": 19, + "hour": 13, + "minute": 10, + "second": 40, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 + } + }, + "offset_start": 873, + "offset_end": 906 + }, + { + "name": { + "Rfc": "mime_version" + }, + "value": { + "Text": "1.0" + }, + "offset_start": 919, + "offset_end": 924 + }, + { + "name": { + "Rfc": "content_type" + }, + "value": { + "ContentType": { + "c_type": "video", + "c_subtype": "avi", + "attributes": null + } + }, + "offset_start": 937, + "offset_end": 948 + } + ], + "is_encoding_problem": false, + "body": { + "InlineBinary": [ + 101 + ] + }, + "offset_header": 868, + "offset_body": 949, + "offset_end": 950 + } + ] +} \ No newline at end of file