Nested message parsing improvements.

This commit is contained in:
Mauro D
2021-12-17 11:47:44 +00:00
parent 715fbbab46
commit c29fcdc8bf
11 changed files with 446 additions and 282 deletions
+5 -1
View File
@@ -65,7 +65,11 @@ fn write_attachments(message: &Message) {
MessagePart::Binary(blob) | MessagePart::InlineBinary(blob) => write_part(blob),
MessagePart::Message(raw_message) => {
write_part(raw_message);
write_attachments(&raw_message.parse().unwrap());
if raw_message.is_parsed() {
write_attachments(raw_message.as_ref().unwrap());
} else {
write_attachments(&raw_message.parse_raw().unwrap());
}
}
_ => (),
}
+66 -10
View File
@@ -416,9 +416,24 @@ impl<'x> MessagePart<'x> {
}
}
pub fn unwrap_message(&self) -> Message {
pub fn unwrap_message(&self) -> &Message {
match self {
MessagePart::Message(part) => part.parse().unwrap(),
MessagePart::Message(part) => {
if part.is_parsed() {
part.as_ref().unwrap()
} else {
panic!(
"This message part has not been parsed yet, use parse_message() instead."
);
}
}
_ => panic!("Expected message part."),
}
}
pub fn parse_message(&'x self) -> Option<Message<'x>> {
match self {
MessagePart::Message(part) => Message::parse(part.body.raw_message.as_ref()),
_ => panic!("Expected message part."),
}
}
@@ -1262,23 +1277,58 @@ impl<'x> ContentType<'x> {
}
}
/// Raw contents of an e-mail message attachment.
#[derive(Debug, PartialEq, Eq)]
/// Contents of an e-mail message attachment.
#[derive(Debug, PartialEq)]
pub struct MessageAttachment<'x> {
pub raw_message: Cow<'x, [u8]>,
pub message: Option<Box<Message<'x>>>,
}
impl<'x> MessageAttachment<'x> {
/// Parse the message attachment and return a `Message` object.
pub fn parse(&'x self) -> Option<Message<'x>> {
pub fn parse_raw(&'x self) -> Option<Message<'x>> {
Message::parse(self.raw_message.as_ref())
}
/// Returns a reference to the parsed `Message` object.
pub fn as_ref(&self) -> Option<&Message> {
self.message.as_ref()?.as_ref().into()
}
/// Returns ```true``` is the message has been parsed.
/// Call `MessageAttachment::parse_raw` when this method returns ```false```,
/// otherwise use `MessageAttachment::as_ref`.
pub fn is_parsed(&self) -> bool {
self.message.is_some()
}
/// Returns the parsed message if available, otherwise
/// parses the raw message and returns the results.
pub fn unwrap(&'x mut self) -> Option<Message<'x>> {
if self.message.is_some() {
(*std::mem::take(&mut self.message).unwrap()).into()
} else {
self.parse_raw()
}
}
}
impl<'x> Part<'x, MessageAttachment<'x>> {
/// Parse the message attachment and return a `Message` object.
pub fn parse(&'x self) -> Option<Message<'x>> {
self.body.parse()
pub fn parse_raw(&'x self) -> Option<Message<'x>> {
self.body.parse_raw()
}
/// Returns a reference to the parsed `Message` object.
pub fn as_ref(&self) -> Option<&Message> {
self.body.as_ref()
}
/// Returns ```true``` is the message has been parsed.
/// Call `MessageAttachment::parse_raw` when this method returns ```false```,
/// otherwise use `MessageAttachment::as_ref`.
pub fn is_parsed(&self) -> bool {
self.body.is_parsed()
}
}
@@ -1287,9 +1337,15 @@ impl<'x> Serialize for MessageAttachment<'x> {
where
S: serde::Serializer,
{
self.parse()
.ok_or_else(|| serde::ser::Error::custom("Failed to parse message attachment."))?
.serialize(serializer)
if let Some(message) = self.message.as_ref() {
message.serialize(serializer)
} else if let Some(message) = self.parse_raw() {
message.serialize(serializer)
} else {
Err(serde::ser::Error::custom(
"Failed to parse message attachment.",
))
}
}
}
+77 -7
View File
@@ -16,8 +16,8 @@ use crate::{
base64::decode_base64, charsets::map::get_charset_decoder,
quoted_printable::decode_quoted_printable, DecodeFnc, DecodeResult,
},
ContentType, HeaderName, HeaderValue, Message, MessagePart, MessagePartId, MessageStructure,
Part, RfcHeaders,
ContentType, HeaderName, HeaderValue, Message, MessageAttachment, MessagePart, MessagePartId,
MessageStructure, Part, RfcHeaders,
};
use super::{
@@ -205,7 +205,9 @@ impl<'x> Message<'x> {
///
pub fn parse(raw_message: &'x [u8]) -> Option<Message<'x>> {
let mut stream = MessageStream::new(raw_message);
let mut message = Message::new();
let mut message_stack = Vec::new();
let mut state = MessageParserState::new();
let mut state_stack = Vec::new();
@@ -298,6 +300,26 @@ impl<'x> Message<'x> {
_ => (true, get_bytes_to_boundary),
};
state
.structure
.push(MessageStructure::Part(message.parts.len()));
if is_binary && mime_type == MimeType::Message {
let new_state = MessageParserState {
mime_type: MimeType::Message,
mime_boundary: state.mime_boundary.take(),
need_html_body: true,
need_text_body: true,
..Default::default()
};
add_missing_type(&mut mime_part_header, "message".into(), "rfc822".into());
message_stack.push((message, std::mem::take(&mut mime_part_header)));
state_stack.push(state);
message = Message::new();
state = new_state;
continue;
}
let (bytes_read, mut bytes) = decode_fnc(
&stream,
stream.pos,
@@ -311,6 +333,7 @@ impl<'x> Message<'x> {
// Attempt to recover contents of an invalid message
if bytes_read == 0 {
if stream.pos >= stream.data.len() || (is_binary && state.mime_boundary.is_none()) {
state.structure.pop();
break;
}
@@ -338,9 +361,11 @@ impl<'x> Message<'x> {
bytes = r_bytes;
stream.pos += bytes_read;
} else {
state.structure.pop();
break;
}
} else {
state.structure.pop();
break;
}
} else {
@@ -354,10 +379,6 @@ impl<'x> Message<'x> {
stream.pos += bytes_read;
}
state
.structure
.push(MessageStructure::Part(message.parts.len()));
if mime_type != MimeType::Message {
let is_inline = is_inline
&& header
@@ -445,15 +466,44 @@ impl<'x> Message<'x> {
message.attachments.push(message.parts.len());
message.parts.push(MessagePart::Message(Part::new(
std::mem::take(&mut mime_part_header),
crate::MessageAttachment {
MessageAttachment {
raw_message: result_to_bytes(bytes, stream.data),
message: None,
},
)));
}
if state.mime_boundary.is_some() {
// Currently processing a MIME part
let mut last_part_offset = stream.pos;
'inner: loop {
if let MimeType::Message = state.mime_type {
// Finished processing nested message, restore parent message from stack
if let (Some((mut prev_message, headers)), Some(mut prev_state)) =
(message_stack.pop(), state_stack.pop())
{
message.structure = state.get_structure();
message.offset_end = seek_crlf_end(&stream, last_part_offset);
prev_message.attachments.push(prev_message.parts.len());
prev_message.parts.push(MessagePart::Message(Part::new(
headers,
MessageAttachment {
raw_message: raw_message
[message.offset_header..message.offset_end]
.into(),
message: Some(Box::new(message)),
},
)));
message = prev_message;
prev_state.mime_boundary = state.mime_boundary;
state = prev_state;
} else {
debug_assert!(false, "Failed to restore parent message. Aborting.");
break 'outer;
}
}
if skip_multipart_end(&mut stream) {
// End of MIME part reached
@@ -486,6 +536,7 @@ impl<'x> Message<'x> {
// Restore ancestor's state
state = prev_state;
last_part_offset = stream.pos;
if let Some(ref mime_boundary) = state.mime_boundary {
// Ancestor has a MIME boundary, seek it.
@@ -506,6 +557,25 @@ impl<'x> Message<'x> {
}
}
while let (Some((mut prev_message, headers)), Some(prev_state)) =
(message_stack.pop(), state_stack.pop())
{
message.offset_end = stream.pos;
if !message.is_empty() {
message.structure = state.get_structure();
prev_message.attachments.push(prev_message.parts.len());
prev_message.parts.push(MessagePart::Message(Part::new(
headers,
MessageAttachment {
raw_message: raw_message[message.offset_header..message.offset_end].into(),
message: Box::new(message).into(),
},
)));
}
message = prev_message;
state = prev_state;
}
message.structure = state.get_structure();
message.offset_end = stream.pos;
+10 -10
View File
@@ -53,8 +53,8 @@ Content-Type: text/plain
"name": {
"Rfc": "content_type"
},
"start": 13,
"end": 29
"start": 43,
"end": 59
}
],
"attachments": [
@@ -85,8 +85,8 @@ Content-Type: text/plain
"name": {
"Rfc": "content_type"
},
"start": 13,
"end": 25
"start": 73,
"end": 85
}
],
"html_body": [
@@ -105,9 +105,9 @@ Content-Type: text/plain
"structure": {
"Part": 0
},
"offset_header": 0,
"offset_body": 26,
"offset_end": 28
"offset_header": 60,
"offset_body": 86,
"offset_end": 88
}
}
}
@@ -115,9 +115,9 @@ Content-Type: text/plain
"structure": {
"Part": 0
},
"offset_header": 0,
"offset_body": 30,
"offset_end": 58
"offset_header": 30,
"offset_body": 60,
"offset_end": 88
}
}
}
+41 -7
View File
@@ -86,8 +86,8 @@ Content-Type: text/plain
"name": {
"Rfc": "content_type"
},
"start": 13,
"end": 25
"start": 141,
"end": 153
}
],
"html_body": [
@@ -106,14 +106,14 @@ Content-Type: text/plain
"structure": {
"Part": 0
},
"offset_header": 0,
"offset_body": 26,
"offset_end": 27
"offset_header": 128,
"offset_body": 154,
"offset_end": 160
}
}
},
{
"Text": {
"Message": {
"headers": {
"content_type": {
"ContentType": {
@@ -122,7 +122,41 @@ Content-Type: text/plain
}
}
},
"body": "Content-Type: text/plain\n\n22\n--1\nContent-Type: message/rfc822\n\nContent-Type: text/plain\n\n333\n"
"body": {
"headers_rfc": {
"content_type": {
"ContentType": {
"c_type": "text",
"c_subtype": "plain"
}
}
},
"headers_offsets": [
{
"name": {
"Rfc": "content_type"
},
"start": 203,
"end": 215
}
],
"attachments": [
0
],
"parts": [
{
"Text": {
"body": "22\n--1\nContent-Type: message/rfc822\n\nContent-Type: text/plain\n\n333\n"
}
}
],
"structure": {
"Part": 0
},
"offset_header": 190,
"offset_body": 216,
"offset_end": 283
}
}
}
],
+44 -44
View File
@@ -74,12 +74,33 @@ Content-Transfer-Encoding: Quoted-printable
---- EXPECTED STRUCTURE ----
{
"headers_rfc": {
"content_type": {
"ContentType": {
"c_type": "multipart",
"c_subtype": "mixed",
"attributes": {
"boundary": "unique-boundary-1"
}
}
},
"mime_version": {
"Text": "1.0"
},
"to": {
"Address": {
"name": "Ned Freed",
"address": "ned@innosoft.com"
}
},
"from": {
"Address": {
"name": "Nathaniel Borenstein",
"address": "nsb@nsb.fv.com"
}
},
"subject": {
"Text": "A multipart example"
},
"date": {
"DateTime": {
"year": 1994,
@@ -92,27 +113,6 @@ Content-Transfer-Encoding: Quoted-printable
"tz_hour": 7,
"tz_minute": 0
}
},
"subject": {
"Text": "A multipart example"
},
"to": {
"Address": {
"name": "Ned Freed",
"address": "ned@innosoft.com"
}
},
"content_type": {
"ContentType": {
"c_type": "multipart",
"c_subtype": "mixed",
"attributes": {
"boundary": "unique-boundary-1"
}
}
},
"mime_version": {
"Text": "1.0"
}
},
"headers_offsets": [
@@ -211,14 +211,14 @@ Content-Transfer-Encoding: Quoted-printable
{
"Text": {
"headers": {
"content_transfer_encoding": {
"Text": "base64"
},
"content_type": {
"ContentType": {
"c_type": "audio",
"c_subtype": "basic"
}
},
"content_transfer_encoding": {
"Text": "base64"
}
},
"body": "... base64-encoded 8000 Hz single-channel\n mu-law-format audio data goes here ...\n"
@@ -227,14 +227,14 @@ Content-Transfer-Encoding: Quoted-printable
{
"Text": {
"headers": {
"content_transfer_encoding": {
"Text": "base64"
},
"content_type": {
"ContentType": {
"c_type": "image",
"c_subtype": "jpeg"
}
},
"content_transfer_encoding": {
"Text": "base64"
}
},
"body": "... base64-encoded image data goes here ...\n"
@@ -265,9 +265,9 @@ Content-Transfer-Encoding: Quoted-printable
},
"body": {
"headers_rfc": {
"from": {
"to": {
"Address": {
"name": "mailbox in US-ASCII"
"name": "address in US-ASCII"
}
},
"content_type": {
@@ -279,9 +279,9 @@ Content-Transfer-Encoding: Quoted-printable
}
}
},
"to": {
"from": {
"Address": {
"name": "address in US-ASCII"
"name": "mailbox in US-ASCII"
}
},
"content_transfer_encoding": {
@@ -296,36 +296,36 @@ Content-Transfer-Encoding: Quoted-printable
"name": {
"Rfc": "from"
},
"start": 5,
"end": 28
"start": 1612,
"end": 1635
},
{
"name": {
"Rfc": "to"
},
"start": 31,
"end": 54
"start": 1638,
"end": 1661
},
{
"name": {
"Rfc": "subject"
},
"start": 62,
"end": 85
"start": 1669,
"end": 1692
},
{
"name": {
"Rfc": "content_type"
},
"start": 98,
"end": 130
"start": 1705,
"end": 1737
},
{
"name": {
"Rfc": "content_transfer_encoding"
},
"start": 156,
"end": 174
"start": 1763,
"end": 1781
}
],
"html_body": [
@@ -344,9 +344,9 @@ Content-Transfer-Encoding: Quoted-printable
"structure": {
"Part": 0
},
"offset_header": 0,
"offset_body": 175,
"offset_end": 223
"offset_header": 1607,
"offset_body": 1782,
"offset_end": 1850
}
}
}
+76 -76
View File
@@ -74,10 +74,13 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz
---- EXPECTED STRUCTURE ----
{
"headers_rfc": {
"to": {
"Address": {
"name": "White House Transportation Coordinator",
"address": "transport@whitehouse.gov"
"content_type": {
"ContentType": {
"c_type": "multipart",
"c_subtype": "mixed",
"attributes": {
"boundary": "D7F------------D7FD5A0B8AB9C65CCDBFA872"
}
}
},
"from": {
@@ -86,13 +89,10 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz
"address": "vice-president@whitehouse.gov"
}
},
"content_type": {
"ContentType": {
"c_type": "multipart",
"c_subtype": "mixed",
"attributes": {
"boundary": "D7F------------D7FD5A0B8AB9C65CCDBFA872"
}
"to": {
"Address": {
"name": "White House Transportation Coordinator",
"address": "transport@whitehouse.gov"
}
},
"subject": {
@@ -161,11 +161,6 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz
{
"Message": {
"headers": {
"content_disposition": {
"ContentType": {
"c_type": "inline"
}
},
"content_transfer_encoding": {
"Text": "7bit"
},
@@ -174,34 +169,17 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz
"c_type": "message",
"c_subtype": "rfc822"
}
},
"content_disposition": {
"ContentType": {
"c_type": "inline"
}
}
},
"body": {
"headers_rfc": {
"from": {
"Address": {
"name": "Bill Clinton",
"address": "president@whitehouse.gov"
}
},
"content_type": {
"ContentType": {
"c_type": "multipart",
"c_subtype": "mixed",
"attributes": {
"boundary": "DC8------------DC8638F443D87A7F0726DEF7"
}
}
},
"received": {
"Collection": [
{
"Text": "from mailhost.whitehouse.gov ([192.168.51.200])\n by heartbeat.whitehouse.gov (8.8.8/8.8.8) with ESMTP id SAA22453\n for <vice-president@heartbeat.whitehouse.gov>;\n Mon, 13 Aug 1998 l8:14:23 +1000"
},
{
"Text": "from the_big_box.whitehouse.gov ([192.168.51.50])\n by mailhost.whitehouse.gov (8.8.8/8.8.7) with ESMTP id RAA20366\n for vice-president@whitehouse.gov; Mon, 13 Aug 1998 17:42:41 +1000"
}
]
"return_path": {
"Text": "president@whitehouse.gov"
},
"message_id": {
"Text": "199804130742.RAA20366@mai1host.whitehouse.gov"
@@ -209,9 +187,6 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz
"subject": {
"Text": "Map of Argentina with Description"
},
"mime_version": {
"Text": "1.0"
},
"date": {
"DateTime": {
"year": 1998,
@@ -225,14 +200,39 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz
"tz_minute": 0
}
},
"return_path": {
"Text": "president@whitehouse.gov"
"received": {
"Collection": [
{
"Text": "from mailhost.whitehouse.gov ([192.168.51.200])\n by heartbeat.whitehouse.gov (8.8.8/8.8.8) with ESMTP id SAA22453\n for <vice-president@heartbeat.whitehouse.gov>;\n Mon, 13 Aug 1998 l8:14:23 +1000"
},
{
"Text": "from the_big_box.whitehouse.gov ([192.168.51.50])\n by mailhost.whitehouse.gov (8.8.8/8.8.7) with ESMTP id RAA20366\n for vice-president@whitehouse.gov; Mon, 13 Aug 1998 17:42:41 +1000"
}
]
},
"content_type": {
"ContentType": {
"c_type": "multipart",
"c_subtype": "mixed",
"attributes": {
"boundary": "DC8------------DC8638F443D87A7F0726DEF7"
}
}
},
"to": {
"Address": {
"name": "A1 Gore (The Enforcer)",
"address": "vice-president@whitehouse.gov"
}
},
"from": {
"Address": {
"name": "Bill Clinton",
"address": "president@whitehouse.gov"
}
},
"mime_version": {
"Text": "1.0"
}
},
"headers_offsets": [
@@ -240,71 +240,71 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz
"name": {
"Rfc": "return_path"
},
"start": 12,
"end": 40
"start": 639,
"end": 667
},
{
"name": {
"Rfc": "received"
},
"start": 49,
"end": 266
"start": 676,
"end": 893
},
{
"name": {
"Rfc": "received"
},
"start": 275,
"end": 473
"start": 902,
"end": 1100
},
{
"name": {
"Rfc": "date"
},
"start": 478,
"end": 511
"start": 1105,
"end": 1138
},
{
"name": {
"Rfc": "message_id"
},
"start": 522,
"end": 571
"start": 1149,
"end": 1198
},
{
"name": {
"Rfc": "from"
},
"start": 576,
"end": 617
"start": 1203,
"end": 1244
},
{
"name": {
"Rfc": "to"
},
"start": 620,
"end": 676
"start": 1247,
"end": 1303
},
{
"name": {
"Rfc": "subject"
},
"start": 684,
"end": 720
"start": 1311,
"end": 1347
},
{
"name": {
"Rfc": "mime_version"
},
"start": 733,
"end": 738
"start": 1360,
"end": 1365
},
{
"name": {
"Rfc": "content_type"
},
"start": 751,
"end": 834
"start": 1378,
"end": 1461
}
],
"html_body": [
@@ -344,6 +344,14 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz
"content_transfer_encoding": {
"Text": "base64"
},
"content_disposition": {
"ContentType": {
"c_type": "inline",
"attributes": {
"fi1ename": "map_of_Argentina.gif"
}
}
},
"content_type": {
"ContentType": {
"c_type": "image",
@@ -352,14 +360,6 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz
"name": "map_of_Argentina.gif"
}
}
},
"content_disposition": {
"ContentType": {
"c_type": "inline",
"attributes": {
"fi1ename": "map_of_Argentina.gif"
}
}
}
},
"body": [
@@ -665,9 +665,9 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz
}
]
},
"offset_header": 0,
"offset_body": 835,
"offset_end": 1978
"offset_header": 627,
"offset_body": 1462,
"offset_end": 2607
}
}
}
+39 -39
View File
@@ -37,14 +37,6 @@ Subject: my different opinion
---- EXPECTED STRUCTURE ----
{
"headers_rfc": {
"to": {
"Address": {
"name": "Recipient-List"
}
},
"subject": {
"Text": "Internet Digest, volume 42"
},
"mime_version": {
"Text": "1.0"
},
@@ -57,6 +49,19 @@ Subject: my different opinion
}
}
},
"subject": {
"Text": "Internet Digest, volume 42"
},
"from": {
"Address": {
"name": "Moderator-Address"
}
},
"to": {
"Address": {
"name": "Recipient-List"
}
},
"date": {
"DateTime": {
"year": 1994,
@@ -69,11 +74,6 @@ Subject: my different opinion
"tz_hour": 0,
"tz_minute": 0
}
},
"from": {
"Address": {
"name": "Moderator-Address"
}
}
},
"headers_offsets": [
@@ -188,22 +188,22 @@ Subject: my different opinion
"name": {
"Rfc": "from"
},
"start": 5,
"end": 19
"start": 423,
"end": 437
},
{
"name": {
"Rfc": "date"
},
"start": 24,
"end": 57
"start": 442,
"end": 475
},
{
"name": {
"Rfc": "subject"
},
"start": 65,
"end": 77
"start": 483,
"end": 495
}
],
"html_body": [
@@ -222,9 +222,9 @@ Subject: my different opinion
"structure": {
"Part": 0
},
"offset_header": 0,
"offset_body": 78,
"offset_end": 100
"offset_header": 418,
"offset_body": 496,
"offset_end": 545
}
}
},
@@ -240,14 +240,6 @@ Subject: my different opinion
},
"body": {
"headers_rfc": {
"from": {
"Address": {
"name": "someone-else-again"
}
},
"subject": {
"Text": "my different opinion"
},
"date": {
"DateTime": {
"year": 1993,
@@ -260,6 +252,14 @@ Subject: my different opinion
"tz_hour": 5,
"tz_minute": 0
}
},
"subject": {
"Text": "my different opinion"
},
"from": {
"Address": {
"name": "someone-else-again"
}
}
},
"headers_offsets": [
@@ -267,22 +267,22 @@ Subject: my different opinion
"name": {
"Rfc": "from"
},
"start": 5,
"end": 25
"start": 550,
"end": 570
},
{
"name": {
"Rfc": "date"
},
"start": 30,
"end": 63
"start": 575,
"end": 608
},
{
"name": {
"Rfc": "subject"
},
"start": 71,
"end": 93
"start": 616,
"end": 638
}
],
"html_body": [
@@ -301,9 +301,9 @@ Subject: my different opinion
"structure": {
"Part": 0
},
"offset_header": 0,
"offset_body": 94,
"offset_end": 125
"offset_header": 545,
"offset_body": 639,
"offset_end": 695
}
}
}
+33 -33
View File
@@ -74,9 +74,6 @@ K
---- EXPECTED STRUCTURE ----
{
"headers_rfc": {
"subject": {
"Text": "RFC 8621 Section 4.1.4 test"
},
"content_type": {
"ContentType": {
"c_type": "multipart",
@@ -85,6 +82,9 @@ K
"boundary": "1"
}
}
},
"subject": {
"Text": "RFC 8621 Section 4.1.4 test"
}
},
"headers_offsets": [
@@ -126,16 +126,16 @@ K
{
"Text": {
"headers": {
"content_disposition": {
"ContentType": {
"c_type": "inline"
}
},
"content_type": {
"ContentType": {
"c_type": "text",
"c_subtype": "plain"
}
},
"content_disposition": {
"ContentType": {
"c_type": "inline"
}
}
},
"body": "A"
@@ -183,16 +183,16 @@ K
{
"Text": {
"headers": {
"content_disposition": {
"ContentType": {
"c_type": "inline"
}
},
"content_type": {
"ContentType": {
"c_type": "text",
"c_subtype": "plain"
}
},
"content_disposition": {
"ContentType": {
"c_type": "inline"
}
}
},
"body": "B"
@@ -221,16 +221,16 @@ K
{
"Text": {
"headers": {
"content_disposition": {
"ContentType": {
"c_type": "inline"
}
},
"content_type": {
"ContentType": {
"c_type": "text",
"c_subtype": "plain"
}
},
"content_disposition": {
"ContentType": {
"c_type": "inline"
}
}
},
"body": "D"
@@ -280,16 +280,16 @@ K
{
"Binary": {
"headers": {
"content_disposition": {
"ContentType": {
"c_type": "attachment"
}
},
"content_type": {
"ContentType": {
"c_type": "image",
"c_subtype": "jpeg"
}
},
"content_disposition": {
"ContentType": {
"c_type": "attachment"
}
}
},
"body": [
@@ -333,8 +333,8 @@ K
"name": {
"Rfc": "subject"
},
"start": 8,
"end": 11
"start": 789,
"end": 792
}
],
"html_body": [
@@ -353,25 +353,25 @@ K
"structure": {
"Part": 0
},
"offset_header": 0,
"offset_body": 12,
"offset_end": 13
"offset_header": 781,
"offset_body": 793,
"offset_end": 798
}
}
},
{
"Text": {
"headers": {
"content_disposition": {
"ContentType": {
"c_type": "inline"
}
},
"content_type": {
"ContentType": {
"c_type": "text",
"c_subtype": "plain"
}
},
"content_disposition": {
"ContentType": {
"c_type": "inline"
}
}
},
"body": "K"
+26 -26
View File
@@ -100,15 +100,15 @@ Foobar
"name": {
"Rfc": "from"
},
"start": 5,
"end": 34
"start": 92,
"end": 121
},
{
"name": {
"Rfc": "subject"
},
"start": 42,
"end": 54
"start": 129,
"end": 141
}
],
"html_body": [
@@ -127,9 +127,9 @@ Foobar
"structure": {
"Part": 0
},
"offset_header": 0,
"offset_body": 55,
"offset_end": 73
"offset_header": 87,
"offset_body": 142,
"offset_end": 166
}
}
},
@@ -160,15 +160,15 @@ Foobar
"name": {
"Rfc": "from"
},
"start": 5,
"end": 32
"start": 171,
"end": 198
},
{
"name": {
"Rfc": "subject"
},
"start": 40,
"end": 52
"start": 206,
"end": 218
}
],
"html_body": [
@@ -187,9 +187,9 @@ Foobar
"structure": {
"Part": 0
},
"offset_header": 0,
"offset_body": 53,
"offset_end": 74
"offset_header": 166,
"offset_body": 219,
"offset_end": 246
}
}
},
@@ -205,15 +205,15 @@ Foobar
},
"body": {
"headers_rfc": {
"subject": {
"Text": "funny hat"
},
"from": {
"Address": {
"name": "attachment",
"address": "attachment@user"
}
},
"subject": {
"Text": "funny hat"
},
"content_type": {
"ContentType": {
"c_type": "multipart",
@@ -229,22 +229,22 @@ Foobar
"name": {
"Rfc": "from"
},
"start": 5,
"end": 35
"start": 251,
"end": 281
},
{
"name": {
"Rfc": "subject"
},
"start": 43,
"end": 54
"start": 289,
"end": 300
},
{
"name": {
"Rfc": "content_type"
},
"start": 67,
"end": 96
"start": 313,
"end": 342
}
],
"html_body": [
@@ -311,9 +311,9 @@ Foobar
}
]
},
"offset_header": 0,
"offset_body": 97,
"offset_end": 318
"offset_header": 246,
"offset_body": 343,
"offset_end": 565
}
}
}
+29 -29
View File
@@ -58,6 +58,9 @@ Root MIME epilogue
---- EXPECTED STRUCTURE ----
{
"headers_rfc": {
"mime_version": {
"Text": "1.0"
},
"content_type": {
"ContentType": {
"c_type": "multipart",
@@ -67,9 +70,6 @@ Root MIME epilogue
}
}
},
"mime_version": {
"Text": "1.0"
},
"from": {
"Address": {
"address": "user@domain.org"
@@ -170,19 +170,8 @@ Root MIME epilogue
},
"body": {
"headers_rfc": {
"from": {
"Address": {
"address": "sub@domain.org"
}
},
"content_type": {
"ContentType": {
"c_type": "multipart",
"c_subtype": "alternative",
"attributes": {
"boundary": "sub1"
}
}
"subject": {
"Text": "submsg"
},
"date": {
"DateTime": {
@@ -197,8 +186,19 @@ Root MIME epilogue
"tz_minute": 0
}
},
"subject": {
"Text": "submsg"
"from": {
"Address": {
"address": "sub@domain.org"
}
},
"content_type": {
"ContentType": {
"c_type": "multipart",
"c_subtype": "alternative",
"attributes": {
"boundary": "sub1"
}
}
}
},
"headers_offsets": [
@@ -206,29 +206,29 @@ Root MIME epilogue
"name": {
"Rfc": "from"
},
"start": 5,
"end": 21
"start": 300,
"end": 316
},
{
"name": {
"Rfc": "date"
},
"start": 26,
"end": 59
"start": 321,
"end": 354
},
{
"name": {
"Rfc": "subject"
},
"start": 67,
"end": 75
"start": 362,
"end": 370
},
{
"name": {
"Rfc": "content_type"
},
"start": 88,
"end": 128
"start": 383,
"end": 423
}
],
"html_body": [
@@ -326,9 +326,9 @@ Root MIME epilogue
}
]
},
"offset_header": 0,
"offset_body": 129,
"offset_end": 414
"offset_header": 295,
"offset_body": 424,
"offset_end": 710
}
}
},