Compare commits

...
5 Commits
Author SHA1 Message Date
Mauro D 41de06fd4e Thread name parsing. 2021-12-22 15:26:30 +00:00
Mauro D 7792452a88 Thread name parsing support. 2021-12-18 10:55:52 +00:00
Mauro D fdf7075e37 MessageAttachment is now an enum. 2021-12-17 18:20:03 +00:00
Mauro D bbb2979e4b Added get_attachment_name() 2021-12-17 11:58:12 +00:00
Mauro D c29fcdc8bf Nested message parsing improvements. 2021-12-17 11:47:44 +00:00
22 changed files with 820 additions and 331 deletions
+5
View File
@@ -1,3 +1,8 @@
mail-parser 0.4.2
================================
- Added `Message::get_thread_name()` to obtain the base subject of a message as defined in [RFC 5957 - Internet Message Access Protocol - SORT and THREAD Extensions (Section 2.1)](https://datatracker.ietf.org/doc/html/rfc5256#section-2.1).
- Added `MimeHeader::get_attachment_name` for simplified access to a MIME attachment file name.
mail-parser 0.4.1
================================
- Lazy parsing of nested e-mail messages.
Generated
+1 -1
View File
@@ -59,7 +59,7 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
[[package]]
name = "mail-parser"
version = "0.4.1"
version = "0.4.2"
dependencies = [
"encoding_rs",
"serde",
+1 -1
View File
@@ -1,7 +1,7 @@
[package]
name = "mail-parser"
description = "Fast and robust e-mail parsing library for Rust"
version = "0.4.1"
version = "0.4.2"
edition = "2018"
authors = [ "Stalwart Labs <hello@stalw.art>"]
license = "Apache-2.0 OR MIT"
+2 -5
View File
@@ -169,11 +169,7 @@ R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
// Full RFC2231 support for continuations and character sets
assert_eq!(
nested_attachment
.get_content_type()
.unwrap()
.get_attribute("name")
.unwrap(),
nested_attachment.get_attachment_name().unwrap(),
"Book about ☕ tables.gif"
);
@@ -228,6 +224,7 @@ and, to run the benchmarks:
- [RFC 2919 - List-Id: A Structured Field and Namespace for the Identification of Mailing Lists](https://datatracker.ietf.org/doc/html/rfc2919)
- [RFC 3339 - Date and Time on the Internet: Timestamps](https://datatracker.ietf.org/doc/html/rfc3339)
- [RFC 8621 - The JSON Meta Application Protocol (JMAP) for Mail (Section 4.1.4)](https://datatracker.ietf.org/doc/html/rfc8621#section-4.1.4)
- [RFC 5957 - Internet Message Access Protocol - SORT and THREAD Extensions (Section 2.1)](https://datatracker.ietf.org/doc/html/rfc5256#section-2.1)
## Supported Character Sets
+1 -5
View File
@@ -143,11 +143,7 @@ R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
// Full RFC2231 support for continuations and character sets
assert_eq!(
nested_attachment
.get_content_type()
.unwrap()
.get_attribute("name")
.unwrap(),
nested_attachment.get_attachment_name().unwrap(),
"Book about ☕ tables.gif"
);
+12 -10
View File
@@ -63,9 +63,17 @@ fn write_attachments(message: &Message) {
match attachment {
MessagePart::Text(text) | MessagePart::Html(text) => write_part(text),
MessagePart::Binary(blob) | MessagePart::InlineBinary(blob) => write_part(blob),
MessagePart::Message(raw_message) => {
write_part(raw_message);
write_attachments(&raw_message.parse().unwrap());
MessagePart::Message(attached_message) => {
// Write attachments of nested messages
match &attached_message.body {
MessageAttachment::Parsed(message) => write_attachments(message.as_ref()),
MessageAttachment::Raw(_) => {
write_attachments(&attached_message.parse_raw().unwrap())
}
}
// Write raw message
write_part(attached_message);
}
_ => (),
}
@@ -74,13 +82,7 @@ fn write_attachments(message: &Message) {
fn write_part<'x>(part: &'x impl BodyPart<'x>) {
std::fs::write(
part.get_content_disposition()
.and_then(|cd| cd.get_attribute("filename"))
.unwrap_or_else(|| {
part.get_content_type()
.and_then(|ct| ct.get_attribute("name"))
.unwrap_or("Untitled")
}),
part.get_attachment_name().unwrap_or("Untitled"),
part.get_contents(),
)
.unwrap();
+1 -1
View File
@@ -42,7 +42,7 @@ dependencies = [
[[package]]
name = "mail-parser"
version = "0.2.1"
version = "0.4.2"
dependencies = [
"encoding_rs",
"serde",
+9 -7
View File
@@ -22,11 +22,12 @@ use mail_parser::{
id::parse_id,
list::parse_comma_separared,
raw::{parse_and_ignore, parse_raw},
thread::{thread_name, trim_trailing_fwd},
unstructured::parse_unstructured,
},
mime::*,
header::parse_header_name,
message::MessageStream,
mime::*,
},
Message,
};
@@ -62,7 +63,7 @@ fuzz_target!(|data: &[u8]| {
parse_content_type(&mut stream);
}
9 => {
parse_header_name(&mut stream);
parse_header_name(&data);
}
10 => {
decode_rfc2047(&mut stream, 0);
@@ -113,26 +114,27 @@ fuzz_target!(|data: &[u8]| {
}
}
// Fuzz HTML functions
// Fuzz text functions
let mut html_str = String::with_capacity(data.len());
let str_data = String::from_utf8_lossy(data);
add_html_token(&mut html_str, str_data.as_ref().as_bytes(), false);
html_to_text(&str_data);
text_to_html(&str_data);
thread_name(&str_data);
trim_trailing_fwd(&str_data);
// Fuzz decoding functions
decode_hex(data);
get_charset_decoder(data);
let decoders: &[for<'x> fn(&'x [u8]) -> String] = &[
for decoder in &[
decoder_utf7,
decoder_utf16_le,
decoder_utf16_be,
decoder_utf16,
decoder_iso_8859_1,
];
for decoder in decoders {
] as &[for<'x> fn(&'x [u8]) -> String]
{
decoder(data);
}
+108 -22
View File
@@ -59,6 +59,7 @@
//! - [RFC 2919 - List-Id: A Structured Field and Namespace for the Identification of Mailing Lists](https://datatracker.ietf.org/doc/html/rfc2919)
//! - [RFC 3339 - Date and Time on the Internet: Timestamps](https://datatracker.ietf.org/doc/html/rfc3339)
//! - [RFC 8621 - The JSON Meta Application Protocol (JMAP) for Mail (Section 4.1.4)](https://datatracker.ietf.org/doc/html/rfc8621#section-4.1.4)
//! - [RFC 5957 - Internet Message Access Protocol - SORT and THREAD Extensions (Section 2.1)](https://datatracker.ietf.org/doc/html/rfc5256#section-2.1)
//!
//! ## Supported Character Sets
//!
@@ -246,11 +247,7 @@
//!
//! // Full RFC2231 support for continuations and character sets
//! assert_eq!(
//! nested_attachment
//! .get_content_type()
//! .unwrap()
//! .get_attribute("name")
//! .unwrap(),
//! nested_attachment.get_attachment_name().unwrap(),
//! "Book about ☕ tables.gif"
//! );
//!
@@ -265,6 +262,7 @@ pub mod parsers;
use std::{borrow::Cow, collections::HashMap, fmt};
use decoders::html::{html_to_text, text_to_html};
use parsers::fields::thread::thread_name;
#[cfg(feature = "serde_support")]
use serde::{Deserialize, Serialize};
@@ -324,6 +322,8 @@ pub struct Message<'x> {
pub offset_header: usize,
pub offset_body: usize,
pub offset_end: usize,
#[cfg_attr(feature = "serde_support", serde(skip))]
pub raw_message: Cow<'x, [u8]>,
}
/// Body structure.
@@ -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) => match &part.body {
MessageAttachment::Parsed(message) => message.as_ref(),
MessageAttachment::Raw(_) => 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) => match &part.body {
MessageAttachment::Parsed(_) => None,
MessageAttachment::Raw(raw_message) => Message::parse(raw_message.as_ref()),
},
_ => panic!("Expected message part."),
}
}
@@ -870,6 +885,11 @@ impl<'x> Message<'x> {
.and_then(|header| header.as_text_ref())
}
/// Returns the message thread name
pub fn get_thread_name(&self) -> Option<&str> {
thread_name(self.get_subject()?).into()
}
/// Returns the To header field
pub fn get_to(&self) -> &HeaderValue<'x> {
self.headers_rfc
@@ -983,6 +1003,15 @@ pub trait MimeHeaders<'x> {
fn get_content_language(&self) -> &HeaderValue<'x>;
/// Returns the Content-Location field
fn get_content_location(&self) -> Option<&str>;
/// Returns the attachment name, if any.
fn get_attachment_name(&self) -> Option<&str> {
self.get_content_disposition()
.and_then(|cd| cd.get_attribute("filename"))
.or_else(|| {
self.get_content_type()
.and_then(|ct| ct.get_attribute("name"))
})
}
}
impl<'x> MimeHeaders<'x> for Message<'x> {
@@ -1110,11 +1139,14 @@ impl<'x> fmt::Display for Part<'x, Cow<'x, [u8]>> {
impl<'x> BodyPart<'x> for Part<'x, MessageAttachment<'x>> {
fn get_contents(&'x self) -> &'x [u8] {
self.body.raw_message.as_ref()
match &self.body {
MessageAttachment::Parsed(msg) => msg.raw_message.as_ref(),
MessageAttachment::Raw(raw) => raw.as_ref(),
}
}
fn get_text_contents(&'x self) -> &'x str {
std::str::from_utf8(self.body.raw_message.as_ref()).unwrap_or("")
std::str::from_utf8(self.get_contents()).unwrap_or("")
}
fn is_text(&self) -> bool {
@@ -1126,13 +1158,16 @@ impl<'x> BodyPart<'x> for Part<'x, MessageAttachment<'x>> {
}
fn len(&self) -> usize {
self.body.raw_message.len()
match &self.body {
MessageAttachment::Parsed(msg) => msg.raw_message.len(),
MessageAttachment::Raw(raw) => raw.len(),
}
}
}
impl<'x> fmt::Display for Part<'x, MessageAttachment<'x>> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.write_str(String::from_utf8_lossy(self.body.raw_message.as_ref()).as_ref())
fmt.write_str(self.get_text_contents())
}
}
@@ -1262,23 +1297,71 @@ impl<'x> ContentType<'x> {
}
}
/// Raw contents of an e-mail message attachment.
#[derive(Debug, PartialEq, Eq)]
pub struct MessageAttachment<'x> {
pub raw_message: Cow<'x, [u8]>,
/// Contents of an e-mail message attachment.
#[derive(Debug, PartialEq)]
pub enum MessageAttachment<'x> {
Parsed(Box<Message<'x>>),
Raw(Cow<'x, [u8]>),
}
impl<'x> Default for MessageAttachment<'x> {
fn default() -> Self {
MessageAttachment::Raw((&[] as &[u8]).into())
}
}
impl<'x> MessageAttachment<'x> {
/// Parse the message attachment and return a `Message` object.
pub fn parse(&'x self) -> Option<Message<'x>> {
Message::parse(self.raw_message.as_ref())
pub fn parse_raw(&'x self) -> Option<Message<'x>> {
if let MessageAttachment::Raw(raw) = self {
Message::parse(raw.as_ref())
} else {
None
}
}
/// Returns a reference to the parsed `Message` object.
pub fn as_ref(&self) -> Option<&Message> {
if let MessageAttachment::Parsed(message) = self {
message.as_ref().into()
} else {
None
}
}
/// 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 {
matches!(self, MessageAttachment::Parsed(_))
}
/*/// Returns the parsed message if available, otherwise
/// parses the raw message and returns the results.
pub fn unwrap(&'x mut self) -> Option<Message<'x>> {
match self {
MessageAttachment::Parsed(message) => (*std::mem::take(&mut message).unwrap()).into(),
MessageAttachment::Raw(raw) => Message::parse(raw.as_ref()),
}
}*/
}
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 +1370,12 @@ 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)
match self {
MessageAttachment::Parsed(message) => message.serialize(serializer),
MessageAttachment::Raw(raw) => Message::parse(raw.as_ref())
.ok_or_else(|| serde::ser::Error::custom("Failed to parse message attachment."))?
.serialize(serializer),
}
}
}
+1
View File
@@ -15,4 +15,5 @@ pub mod date;
pub mod id;
pub mod list;
pub mod raw;
pub mod thread;
pub mod unstructured;
+308
View File
@@ -0,0 +1,308 @@
/*
* Copyright Stalwart Labs, Minter Ltd. See the COPYING
* file at the top-level directory of this distribution.
*
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
* https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
* <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
* option. This file may not be copied, modified, or distributed
* except according to those terms.
*/
static RE_PREFIXES: &[&str] = &[
"re", "res", "sv", "antw", "ref", "aw", "απ", "השב", "vá", "r", "rif", "bls", "odp", "ynt",
"atb", "رد", "回复", "转发",
];
static FWD_PREFIXES: &[&str] = &[
"fwd",
"fw",
"rv",
"enc",
"vs",
"doorst",
"vl",
"tr",
"wg",
"πρθ",
"הועבר",
"továbbítás",
"i",
"fs",
"trs",
"vb",
"pd",
"i̇lt",
"yml",
"إعادة توجيه",
"回覆",
"轉寄",
];
pub fn thread_name(text: &str) -> &str {
let mut token_start = 0;
let mut token_end = 0;
let mut thread_name_start = 0;
let mut fwd_start = 0;
let mut fwd_end = 0;
let mut last_blob_end = 0;
let mut in_blob = false;
let mut in_blob_ignore = false;
let mut seen_header = false;
let mut seen_blob_header = false;
let mut token_found = false;
for (pos, ch) in text.char_indices() {
match ch {
'[' => {
if !in_blob {
if token_found {
if token_end == 0 {
token_end = pos;
}
let prefix = text[token_start..token_end].to_lowercase();
if RE_PREFIXES.contains(&prefix.as_ref())
|| FWD_PREFIXES.contains(&prefix.as_ref())
{
seen_header = true;
} else {
break;
}
}
token_found = false;
in_blob = true;
} else {
break;
}
}
']' if in_blob => {
if seen_blob_header && token_found {
fwd_start = token_start;
fwd_end = pos;
}
if !seen_header {
last_blob_end = pos + 1;
}
in_blob = false;
token_found = false;
seen_blob_header = false;
in_blob_ignore = false;
}
':' if !in_blob => {
if (seen_header && token_found) || (!seen_header && !token_found) {
break;
} else if !seen_header {
if token_end == 0 {
token_end = pos;
}
let prefix = text[token_start..token_end].to_lowercase();
if !RE_PREFIXES.contains(&prefix.as_ref())
&& !FWD_PREFIXES.contains(&prefix.as_ref())
{
break;
}
} else {
seen_header = false;
}
thread_name_start = pos + 1;
token_found = false;
}
':' if in_blob && !in_blob_ignore => {
if token_end == 0 {
token_end = pos;
}
let prefix = text[token_start..token_end].to_lowercase();
if FWD_PREFIXES.contains(&prefix.as_ref()) {
token_found = false;
seen_blob_header = true;
} else if seen_blob_header && RE_PREFIXES.contains(&prefix.as_ref()) {
token_found = false;
} else {
in_blob_ignore = true;
}
}
_ if ch.is_whitespace() => {
if token_end == 0 {
token_end = pos;
}
}
_ => {
if !token_found {
token_start = pos;
token_end = 0;
token_found = true;
} else if !in_blob && pos - token_start > 21 {
break;
}
}
}
}
if last_blob_end > thread_name_start
|| (fwd_start > 0 && last_blob_end > fwd_start && fwd_start > thread_name_start)
{
let result = trim_trailing_fwd(&text[last_blob_end..]);
if !result.is_empty() {
return result;
}
}
if fwd_start > 0 && thread_name_start < fwd_start {
let result = trim_trailing_fwd(&text[fwd_start..fwd_end]);
if !result.is_empty() {
return result;
}
}
trim_trailing_fwd(&text[thread_name_start..])
}
pub fn trim_trailing_fwd(text: &str) -> &str {
let mut in_parentheses = false;
let mut trim_end = true;
let mut end_found = false;
let mut text_start = 0;
let mut text_end = text.len();
let mut fwd_end = 0;
for (pos, ch) in text.char_indices().rev() {
match ch {
'(' if !end_found => {
if in_parentheses {
in_parentheses = false;
if fwd_end - pos > 2
&& FWD_PREFIXES.contains(&text[pos + 1..fwd_end].to_lowercase().as_ref())
{
text_end = pos;
trim_end = true;
continue;
}
}
end_found = true;
}
')' if !end_found => {
if !in_parentheses {
in_parentheses = true;
fwd_end = pos;
} else {
end_found = true;
}
}
_ if ch.is_whitespace() => {
if trim_end {
text_end = pos;
}
continue;
}
_ => {
if !in_parentheses && !end_found {
end_found = true;
}
}
}
if trim_end {
trim_end = false;
}
text_start = pos;
}
if text_end >= text_start {
&text[text_start..text_end]
} else {
""
}
}
#[cfg(test)]
mod tests {
use crate::parsers::fields::thread::{thread_name, trim_trailing_fwd};
#[test]
fn parse_thread_name() {
let tests = [
("re: hello", "hello"),
("re:re: hello", "hello"),
("re:fwd: hello", "hello"),
("fwd[5]:re[5]: hello", "hello"),
("fwd[99]: re[40]: hello", "hello"),
(": hello", ": hello"),
("z: hello", "z: hello"),
("re:: hello", ": hello"),
("[10] hello", "hello"),
("fwd[a]: hello", "hello"),
("re:", ""),
("re::", ":"),
("", ""),
(" ", ""),
("回复: 轉寄: 轉寄", "轉寄"),
("aw[50]: wg: aw[1]: hallo", "hallo"),
("res: rv: enc: továbbítás: ", ""),
("[fwd: hello world]", "hello world"),
("re: enc: re[5]: [fwd: hello world]", "hello world"),
("[fwd: re: fw: hello world]", "hello world"),
("[fwd: hello world]: another text", ": another text"),
("[fwd: re: fwd:] another text", "another text"),
("[hello world]", "[hello world]"),
("re: fwd[9]: [hello world]", "[hello world]"),
("[mailing-list] hello world", "hello world"),
("[mailing-list] re: hello world", "hello world"),
("[mailing-list] wg[8]:re: hello world", "hello world"),
("hello [world]", "hello [world]"),
(" [hello] [world] ", "[hello] [world]"),
("[mailing-list] hello [world]", "hello [world]"),
("[hello [world]", "[hello [world]"),
("[]hello [world]", "hello [world]"),
("[fwd: re: re:] fwd[6]:re: fw:", ""),
("[fwd hello] world hello", "world hello"),
("[fwd: مرحبا بالعالم]", "مرحبا بالعالم"),
("[fwd: hello world] مرحبا بالعالم", "مرحبا بالعالم"),
(" hello world ", "hello world"),
(
"[mailing-list] wg[8]:re: hello world (fwd)(fwd)",
"hello world",
),
("[fwd: re: fw: hello world (fwd)]", "hello world"),
(
"res: rv: enc: továbbítás: hello world (doorst)",
"hello world",
),
("[fwd: re: re: (fwd)] fwd[6]:re: fw: (fwd)", ""),
];
for (input, expected) in tests {
assert_eq!(thread_name(input), expected, "{:?}", input);
}
}
#[test]
fn parse_trail_fwd() {
let tests = [
("hello (fwd)", "hello"),
(" hello (fwd)(fwd)", "hello"),
("hello (wg) (fwd) (fwd)", "hello"),
("(fwd)(fwd)", ""),
("(fwd)hello(fwd)", "(fwd)hello"),
(" hello ", "hello"),
(" hello world ", "hello world"),
("", ""),
(" ", ""),
("hello ()(fwd)", "hello ()"),
("(hello)", "(hello)"),
("hello () (fwd) ()(fwd)", "hello () (fwd) ()"),
(")(", ")("),
(" 你好世界(fwd) ", "你好世界"),
("你好世界 (回覆)", "你好世界"),
("hello(fwd", "hello(fwd"),
("hello(fwd))", "hello(fwd))"),
];
for (input, expected) in tests {
assert_eq!(trim_trailing_fwd(input), expected, "{:?}", input);
}
}
}
-1
View File
@@ -106,7 +106,6 @@ pub fn parse_unstructured<'x>(stream: &mut MessageStream<'x>) -> HeaderValue<'x>
#[cfg(test)]
mod tests {
#[test]
fn parse_unstructured_text() {
use crate::parsers::fields::unstructured::parse_unstructured;
+72 -9
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,38 @@ 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 {
raw_message: result_to_bytes(bytes, stream.data),
},
MessageAttachment::Raw(result_to_bytes(bytes, stream.data)),
)));
}
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);
message.raw_message =
raw_message[message.offset_header..message.offset_end].into();
prev_message.attachments.push(prev_message.parts.len());
prev_message.parts.push(MessagePart::Message(Part::new(
headers,
MessageAttachment::Parsed(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 +530,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 +551,24 @@ 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();
message.raw_message = raw_message[message.offset_header..message.offset_end].into();
prev_message.attachments.push(prev_message.parts.len());
prev_message.parts.push(MessagePart::Message(Part::new(
headers,
MessageAttachment::Parsed(Box::new(message)),
)));
}
message = prev_message;
state = prev_state;
}
message.raw_message = raw_message.into();
message.structure = state.get_structure();
message.offset_end = stream.pos;
+1 -5
View File
@@ -128,11 +128,7 @@ R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
let nested_attachment = nested_message.get_attachment(0).unwrap().unwrap_binary();
assert_eq!(nested_attachment.len(), 42);
assert_eq!(
nested_attachment
.get_content_type()
.unwrap()
.get_attribute("name")
.unwrap(),
nested_attachment.get_attachment_name().unwrap(),
"Book about ☕ tables.gif"
);
+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
}
}
},