diff --git a/Cargo.lock b/Cargo.lock index cf865ac..9198c53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,7 +59,7 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "mail-parser" -version = "0.2.2" +version = "0.3.0" dependencies = [ "encoding_rs", "serde", diff --git a/Cargo.toml b/Cargo.toml index 5f93210..8ad3d34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "mail-parser" description = "Fast and robust e-mail parsing library for Rust" -version = "0.2.2" +version = "0.3.0" edition = "2018" authors = [ "Stalwart Labs "] license = "Apache-2.0 OR MIT" diff --git a/README.md b/README.md index b95f0ae..db4faf3 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Twitter Follow](https://img.shields.io/twitter/follow/stalwartlabs?style=social)](https://twitter.com/stalwartlabs) _mail-parser_ is an **e-mail parsing library** written in Rust that fully conforms to the Internet Message Format standard (_RFC 5322_), the -Multipurpose Internet Mail Extensions (MIME; _RFC 2045 - 2049_) as well as other [internet messaging RFCs](#conformed-rfcs). +Multipurpose Internet Mail Extensions (MIME; _RFC 2045 - 2049_) as well as many other [internet messaging RFCs](#conformed-rfcs). It also supports decoding messages in [41 different character sets](#supported-character-sets) including obsolete formats such as UTF-7. All Unicode (UTF-*) and single-byte character sets are handled internally by the library while support for legacy multi-byte encodings of Chinese @@ -72,19 +72,19 @@ Performance and memory safety were two important factors while designing _mail-p ) .as_bytes(); - let message = Message::parse(input); + let message = Message::parse(input).unwrap(); // Parses addresses (including comments), lists and groups assert_eq!( message.get_from(), - &Address::Address(Addr { + &HeaderValue::Address(Addr { name: Some("Art Vandelay (Vandelay Industries)".into()), address: Some("art@vandelay.com".into()) }) ); assert_eq!( message.get_to(), - &Address::GroupList(vec![ + &HeaderValue::GroupList(vec![ Group { name: Some("Colleagues".into()), addresses: vec![Addr { @@ -169,8 +169,6 @@ Performance and memory safety were two important factors while designing _mail-p // Full RFC2231 support for continuations and character sets assert_eq!( nested_attachment - .get_header() - .unwrap() .get_content_type() .unwrap() .get_attribute("name") @@ -219,11 +217,15 @@ and, to run the benchmarks: - [RFC 2048 - Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures](https://datatracker.ietf.org/doc/html/rfc2048) - [RFC 2049 - Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples](https://datatracker.ietf.org/doc/html/rfc2049) - [RFC 2231 - MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations](https://datatracker.ietf.org/doc/html/rfc2231) +- [RFC 2557 - MIME Encapsulation of Aggregate Documents, such as HTML (MHTML)](https://datatracker.ietf.org/doc/html/rfc2557) - [RFC 2183 - Communicating Presentation Information in Internet Messages: The Content-Disposition Header Field](https://datatracker.ietf.org/doc/html/rfc2183) +- [RFC 2392 - Content-ID and Message-ID Uniform Resource Locators](https://datatracker.ietf.org/doc/html/rfc2392) +- [RFC 3282 - Content Language Headers](https://datatracker.ietf.org/doc/html/rfc3282) - [RFC 6532 - Internationalized Email Headers](https://datatracker.ietf.org/doc/html/rfc6532) - [RFC 2152 - UTF-7 - A Mail-Safe Transformation Format of Unicode](https://datatracker.ietf.org/doc/html/rfc2152) - [RFC 2369 - The Use of URLs as Meta-Syntax for Core Mail List Commands and their Transport through Message Header Fields](https://datatracker.ietf.org/doc/html/rfc2369) - [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) ## Supported Character Sets diff --git a/examples/email_to_json_and_yaml.rs b/examples/email_to_json_and_yaml.rs index 62154ce..775763d 100644 --- a/examples/email_to_json_and_yaml.rs +++ b/examples/email_to_json_and_yaml.rs @@ -9,7 +9,7 @@ * except according to those terms. */ -use mail_parser::{Addr, Address, BodyPart, Group, Message, MessagePart, MimeFieldGet}; +use mail_parser::*; fn main() { let input = concat!( @@ -49,19 +49,19 @@ fn main() { ) .as_bytes(); - let message = Message::parse(input); + let message = Message::parse(input).unwrap(); // Parses addresses (including comments), lists and groups assert_eq!( message.get_from(), - &Address::Address(Addr { + &HeaderValue::Address(Addr { name: Some("Art Vandelay (Vandelay Industries)".into()), address: Some("art@vandelay.com".into()) }) ); assert_eq!( message.get_to(), - &Address::GroupList(vec![ + &HeaderValue::GroupList(vec![ Group { name: Some("Colleagues".into()), addresses: vec![Addr { @@ -146,8 +146,6 @@ fn main() { // Full RFC2231 support for continuations and character sets assert_eq!( nested_attachment - .get_header() - .unwrap() .get_content_type() .unwrap() .get_attribute("name") diff --git a/src/lib.rs b/src/lib.rs index 5ba379c..e7ed969 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,7 @@ //! # mail-parser //! //! _mail-parser_ is an **e-mail parsing library** written in Rust that fully conforms to the Internet Message Format standard (_RFC 5322_), the -//! Multipurpose Internet Mail Extensions (MIME; _RFC 2045 - 2049_) as well as other [internet messaging RFCs](#conformed-rfcs). +//! Multipurpose Internet Mail Extensions (MIME; _RFC 2045 - 2049_) as well as many other [internet messaging RFCs](#conformed-rfcs). //! //! It also supports decoding messages in [41 different character sets](#supported-character-sets) including obsolete formats such as UTF-7. //! All Unicode (UTF-*) and single-byte character sets are handled internally by the library while support for legacy multi-byte encodings of Chinese @@ -49,11 +49,15 @@ //! - [RFC 2048 - Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures](https://datatracker.ietf.org/doc/html/rfc2048) //! - [RFC 2049 - Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples](https://datatracker.ietf.org/doc/html/rfc2049) //! - [RFC 2231 - MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations](https://datatracker.ietf.org/doc/html/rfc2231) +//! - [RFC 2557 - MIME Encapsulation of Aggregate Documents, such as HTML (MHTML)](https://datatracker.ietf.org/doc/html/rfc2557) //! - [RFC 2183 - Communicating Presentation Information in Internet Messages: The Content-Disposition Header Field](https://datatracker.ietf.org/doc/html/rfc2183) +//! - [RFC 2392 - Content-ID and Message-ID Uniform Resource Locators](https://datatracker.ietf.org/doc/html/rfc2392) +//! - [RFC 3282 - Content Language Headers](https://datatracker.ietf.org/doc/html/rfc3282) //! - [RFC 6532 - Internationalized Email Headers](https://datatracker.ietf.org/doc/html/rfc6532) //! - [RFC 2152 - UTF-7 - A Mail-Safe Transformation Format of Unicode](https://datatracker.ietf.org/doc/html/rfc2152) //! - [RFC 2369 - The Use of URLs as Meta-Syntax for Core Mail List Commands and their Transport through Message Header Fields](https://datatracker.ietf.org/doc/html/rfc2369) //! - [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) //! //! ## Supported Character Sets @@ -145,19 +149,19 @@ //! ) //! .as_bytes(); //! -//! let message = Message::parse(input); +//! let message = Message::parse(input).unwrap(); //! //! // Parses addresses (including comments), lists and groups //! assert_eq!( //! message.get_from(), -//! &Address::Address(Addr { +//! &HeaderValue::Address(Addr { //! name: Some("Art Vandelay (Vandelay Industries)".into()), //! address: Some("art@vandelay.com".into()) //! }) //! ); //! assert_eq!( //! message.get_to(), -//! &Address::GroupList(vec![ +//! &HeaderValue::GroupList(vec![ //! Group { //! name: Some("Colleagues".into()), //! addresses: vec![Addr { @@ -242,8 +246,6 @@ //! // Full RFC2231 support for continuations and character sets //! assert_eq!( //! nested_attachment -//! .get_header() -//! .unwrap() //! .get_content_type() //! .unwrap() //! .get_attribute("name") @@ -269,7 +271,13 @@ use serde::{Deserialize, Serialize}; #[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] pub struct Message<'x> { #[cfg_attr(feature = "serde_support", serde(borrow))] - header: Box>, + #[cfg_attr( + feature = "serde_support", + serde(skip_serializing_if = "HashMap::is_empty") + )] + #[cfg_attr(feature = "serde_support", serde(default))] + headers: Headers<'x>, + #[cfg_attr( feature = "serde_support", serde(skip_serializing_if = "Vec::is_empty") @@ -299,7 +307,7 @@ pub struct TextPart<'x> { serde(skip_serializing_if = "Option::is_none") )] #[cfg_attr(feature = "serde_support", serde(default))] - header: Option>, + headers: Option>, contents: Cow<'x, str>, } @@ -312,7 +320,7 @@ pub struct BinaryPart<'x> { serde(skip_serializing_if = "Option::is_none") )] #[cfg_attr(feature = "serde_support", serde(default))] - header: Option>, + headers: Option>, #[cfg_attr(feature = "serde_support", serde(with = "serde_bytes"))] #[cfg_attr(feature = "serde_support", serde(borrow))] contents: Cow<'x, [u8]>, @@ -352,265 +360,6 @@ pub enum MessagePart<'x> { Message(Message<'x>), } -/// An RFC5322 message header. -#[derive(PartialEq, Debug, Default)] -#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] -pub struct MessageHeader<'x> { - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub bcc: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub cc: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub comments: Option>>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub date: Option, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub from: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub in_reply_to: Option>>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub keywords: Option>>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub list_archive: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub list_help: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub list_id: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub list_owner: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub list_post: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub list_subscribe: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub list_unsubscribe: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub message_id: Option>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub mime_version: Option>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub received: Option>>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub references: Option>>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub reply_to: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub resent_bcc: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub resent_cc: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub resent_date: Option>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub resent_from: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub resent_message_id: Option>>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub resent_sender: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub resent_to: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub return_path: Option>>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub sender: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub subject: Option>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Address::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub to: Address<'x>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub content_description: Option>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub content_disposition: Option>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub content_id: Option>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub content_transfer_encoding: Option>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub content_type: Option>, - #[cfg_attr(feature = "serde_support", serde(borrow))] - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "HashMap::is_empty") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub others: HashMap<&'x str, Vec>>, -} - -/// A MIME header. -#[derive(PartialEq, Debug, Default)] -#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] -pub struct MimeHeader<'x> { - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub content_description: Option>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub content_disposition: Option>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub content_id: Option>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub content_transfer_encoding: Option>, - #[cfg_attr( - feature = "serde_support", - serde(skip_serializing_if = "Option::is_none") - )] - #[cfg_attr(feature = "serde_support", serde(default))] - pub content_type: Option>, -} - /// An RFC5322 or RFC2369 internet address. #[derive(Debug, PartialEq)] #[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] @@ -653,10 +402,58 @@ pub struct Group<'x> { pub addresses: Vec>, } -/// An RFC5322 or RFC2369 address field. +pub type Headers<'x> = HashMap>; + +/// A header field +#[repr(u8)] +#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] +#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde_support", serde(rename_all = "snake_case"))] +pub enum HeaderName { + Subject = 0, + From = 1, + To = 2, + Cc = 3, + Date = 4, + Bcc = 5, + ReplyTo = 6, + Sender = 7, + Comments = 8, + InReplyTo = 9, + Keywords = 10, + Received = 11, + MessageId = 12, + References = 13, + ReturnPath = 14, + MimeVersion = 15, + ContentDescription = 16, + ContentId = 17, + ContentLanguage = 18, + ContentLocation = 19, + ContentTransferEncoding = 20, + ContentType = 21, + ContentDisposition = 22, + ResentTo = 23, + ResentFrom = 24, + ResentBcc = 25, + ResentCc = 26, + ResentSender = 27, + ResentDate = 28, + ResentMessageId = 29, + ListArchive = 30, + ListHelp = 31, + ListId = 32, + ListOwner = 33, + ListPost = 34, + ListSubscribe = 35, + ListUnsubscribe = 36, + Unsupported = 37, +} + +/// A parsed header value. #[derive(Debug, PartialEq)] #[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] -pub enum Address<'x> { +pub enum HeaderValue<'x> { /// A single address Address(Addr<'x>), @@ -666,16 +463,89 @@ pub enum Address<'x> { /// A group of addresses Group(Group<'x>), - /// A list containing two or more groups + /// A list containing two or more address groups GroupList(Vec>), - /// A collection of address fields, used for header fields - /// that might be present more than once in a message, - /// for example Resent-To - Collection(Vec>), + /// A string + Text(Cow<'x, str>), + + /// A list of strings + TextList(Vec>), + + /// A datetime + DateTime(DateTime), + + /// A Content-Type or Content-Disposition header + ContentType(ContentType<'x>), + + /// A collection of multiple header fields, for example + /// Resent-To, References, etc. + Collection(Vec>), Empty, } +impl<'x> Default for HeaderValue<'x> { + fn default() -> Self { + HeaderValue::Empty + } +} + +impl<'x> HeaderValue<'x> { + pub fn is_empty(&self) -> bool { + *self == HeaderValue::Empty + } + + pub fn unwrap_text(&mut self) -> Cow<'x, str> { + match std::mem::take(self) { + HeaderValue::Text(s) => s, + _ => panic!("HeaderValue::unwrap_text called on non-Text value"), + } + } + + pub fn unwrap_datetime(&mut self) -> DateTime { + match std::mem::take(self) { + HeaderValue::DateTime(d) => d, + _ => panic!("HeaderValue::unwrap_datetime called on non-DateTime value"), + } + } + + pub fn unwrap_content_type(&mut self) -> ContentType<'x> { + match std::mem::take(self) { + HeaderValue::ContentType(c) => c, + _ => panic!("HeaderValue::unwrap_content_type called on non-ContentType value"), + } + } + + pub fn as_text_ref(&self) -> Option<&str> { + match *self { + HeaderValue::Text(ref s) => Some(s), + HeaderValue::TextList(ref l) => l.get(0)?.as_ref().into(), + _ => None, + } + } + + pub fn get_content_type(&self) -> &ContentType<'x> { + match *self { + HeaderValue::ContentType(ref ct) => ct, + _ => panic!("HeaderValue::get_content_type called on non-ContentType value"), + } + } + + pub fn as_content_type_ref(&self) -> Option<&ContentType> { + match *self { + HeaderValue::ContentType(ref c) => Some(c), + _ => None, + } + } + + pub fn as_datetime_ref(&self) -> Option<&DateTime> { + match *self { + HeaderValue::DateTime(ref d) => Some(d), + _ => None, + } + } +} + /// An RFC2047 Content-Type or RFC2183 Content-Disposition MIME header field. #[derive(Debug, PartialEq)] #[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] @@ -710,174 +580,215 @@ pub struct DateTime { tz_minute: u32, } -/// MIME header fields. -pub trait MimeFieldGet<'x> { - /// Content-Description MIME header - fn get_content_description(&self) -> Option<&Cow<'x, str>>; - /// Content-Disposition MIME header - fn get_content_disposition(&self) -> Option<&ContentType<'x>>; - /// Content-ID MIME header - fn get_content_id(&self) -> Option<&Cow<'x, str>>; - /// Content-Transfer-Encoding MIME header - fn get_content_transfer_encoding(&self) -> Option<&Cow<'x, str>>; - /// Content-Type MIME header - fn get_content_type(&self) -> Option<&ContentType<'x>>; -} - impl<'x> Message<'x> { /// Returns the BCC header field - pub fn get_bcc(&self) -> &Address<'x> { - &self.header.bcc + pub fn get_bcc(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::Bcc) + .unwrap_or(&HeaderValue::Empty) } /// Returns the CC header field - pub fn get_cc(&self) -> &Address<'x> { - &self.header.cc + pub fn get_cc(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::Cc) + .unwrap_or(&HeaderValue::Empty) } /// Returns all Comments header fields - pub fn get_comments(&self) -> Option<&Vec>> { - self.header.comments.as_ref() + pub fn get_comments(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::Comments) + .unwrap_or(&HeaderValue::Empty) } /// Returns the Date header field pub fn get_date(&self) -> Option<&DateTime> { - self.header.date.as_ref() + self.headers + .get(&HeaderName::Date) + .and_then(|header| header.as_datetime_ref()) } /// Returns the From header field - pub fn get_from(&self) -> &Address<'x> { - &self.header.from + pub fn get_from(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::From) + .unwrap_or(&HeaderValue::Empty) } /// Returns all In-Reply-To header fields - pub fn get_in_reply_to(&self) -> Option<&Vec>> { - self.header.in_reply_to.as_ref() + pub fn get_in_reply_to(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::InReplyTo) + .unwrap_or(&HeaderValue::Empty) } /// Returns all Keywords header fields - pub fn get_keywords(&self) -> Option<&Vec>> { - self.header.keywords.as_ref() + pub fn get_keywords(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::Keywords) + .unwrap_or(&HeaderValue::Empty) } /// Returns the List-Archive header field - pub fn get_list_archive(&self) -> &Address<'x> { - &self.header.list_archive + pub fn get_list_archive(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ListArchive) + .unwrap_or(&HeaderValue::Empty) } /// Returns the List-Help header field - pub fn get_list_help(&self) -> &Address<'x> { - &self.header.list_help + pub fn get_list_help(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ListHelp) + .unwrap_or(&HeaderValue::Empty) } /// Returns the List-ID header field - pub fn get_list_id(&self) -> &Address<'x> { - &self.header.list_id + pub fn get_list_id(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ListId) + .unwrap_or(&HeaderValue::Empty) } /// Returns the List-Owner header field - pub fn get_list_owner(&self) -> &Address<'x> { - &self.header.list_owner + pub fn get_list_owner(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ListOwner) + .unwrap_or(&HeaderValue::Empty) } - /// Returns the List-Port header field - pub fn get_list_post(&self) -> &Address<'x> { - &self.header.list_post + /// Returns the List-Post header field + pub fn get_list_post(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ListPost) + .unwrap_or(&HeaderValue::Empty) } /// Returns the List-Subscribe header field - pub fn get_list_subscribe(&self) -> &Address<'x> { - &self.header.list_subscribe + pub fn get_list_subscribe(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ListSubscribe) + .unwrap_or(&HeaderValue::Empty) } /// Returns the List-Unsubscribe header field - pub fn get_list_unsubscribe(&self) -> &Address<'x> { - &self.header.list_unsubscribe + pub fn get_list_unsubscribe(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ListUnsubscribe) + .unwrap_or(&HeaderValue::Empty) } /// Returns the Message-ID header field - pub fn get_message_id(&self) -> Option<&Cow<'x, str>> { - self.header.message_id.as_ref() + pub fn get_message_id(&self) -> Option<&str> { + self.headers + .get(&HeaderName::MessageId) + .and_then(|header| header.as_text_ref()) } /// Returns the MIME-Version header field - pub fn get_mime_version(&self) -> Option<&Cow<'x, str>> { - self.header.mime_version.as_ref() + pub fn get_mime_version(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::MimeVersion) + .unwrap_or(&HeaderValue::Empty) } /// Returns all Received header fields - pub fn get_received(&self) -> Option<&Vec>> { - self.header.received.as_ref() + pub fn get_received(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::Received) + .unwrap_or(&HeaderValue::Empty) } /// Returns all References header fields - pub fn get_references(&self) -> Option<&Vec>> { - self.header.references.as_ref() + pub fn get_references(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::References) + .unwrap_or(&HeaderValue::Empty) } /// Returns the Reply-To header field - pub fn get_reply_to(&self) -> &Address<'x> { - &self.header.reply_to + pub fn get_reply_to(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ReplyTo) + .unwrap_or(&HeaderValue::Empty) } /// Returns the Resent-BCC header field - pub fn get_resent_bcc(&self) -> &Address<'x> { - &self.header.bcc + pub fn get_resent_bcc(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ResentBcc) + .unwrap_or(&HeaderValue::Empty) } /// Returns the Resent-CC header field - pub fn get_resent_cc(&self) -> &Address<'x> { - &self.header.resent_to + pub fn get_resent_cc(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ResentTo) + .unwrap_or(&HeaderValue::Empty) } /// Returns all Resent-Date header fields - pub fn get_resent_date(&self) -> Option<&Vec> { - self.header.resent_date.as_ref() + pub fn get_resent_date(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ResentDate) + .unwrap_or(&HeaderValue::Empty) } /// Returns the Resent-From header field - pub fn get_resent_from(&self) -> &Address<'x> { - &self.header.resent_from + pub fn get_resent_from(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ResentFrom) + .unwrap_or(&HeaderValue::Empty) } /// Returns all Resent-Message-ID header fields - pub fn get_resent_message_id(&self) -> Option<&Vec>> { - self.header.resent_message_id.as_ref() + pub fn get_resent_message_id(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ResentMessageId) + .unwrap_or(&HeaderValue::Empty) } /// Returns the Sender header field - pub fn get_resent_sender(&self) -> &Address<'x> { - &self.header.resent_sender + pub fn get_resent_sender(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ResentSender) + .unwrap_or(&HeaderValue::Empty) } /// Returns the Resent-To header field - pub fn get_resent_to(&self) -> &Address<'x> { - &self.header.resent_to + pub fn get_resent_to(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ResentTo) + .unwrap_or(&HeaderValue::Empty) } /// Returns all Return-Path header fields - pub fn get_return_path(&self) -> Option<&Vec>> { - self.header.return_path.as_ref() + pub fn get_return_path(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ReturnPath) + .unwrap_or(&HeaderValue::Empty) } /// Returns the Sender header field - pub fn get_sender(&self) -> &Address<'x> { - &self.header.sender + pub fn get_sender(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::Sender) + .unwrap_or(&HeaderValue::Empty) } /// Returns the Subject header field - pub fn get_subject(&self) -> Option<&Cow<'x, str>> { - self.header.subject.as_ref() + pub fn get_subject(&self) -> Option<&str> { + self.headers + .get(&HeaderName::Subject) + .and_then(|header| header.as_text_ref()) } /// Returns the To header field - pub fn get_to(&self) -> &Address<'x> { - &self.header.to - } - - /// Returns any other message header not specified in RFCs 5322, 2045-2049, 2183, 2369 or 2919. - pub fn get_header(&self, name: &str) -> Option<&Vec>> { - self.header.others.get(name) + pub fn get_to(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::To) + .unwrap_or(&HeaderValue::Empty) } fn get_body_part(&self, list: &'x [InlinePart<'x>], pos: usize) -> Option<&'x dyn BodyPart> { @@ -938,141 +849,70 @@ impl<'x> Message<'x> { } } -impl<'x> MessageHeader<'x> { - pub fn is_empty(&self) -> bool { - for addr in [ - &self.from, - &self.to, - &self.cc, - &self.bcc, - &self.reply_to, - &self.sender, - &self.resent_to, - &self.resent_from, - &self.resent_bcc, - &self.resent_cc, - &self.resent_sender, - &self.list_archive, - &self.list_help, - &self.list_id, - &self.list_owner, - &self.list_post, - &self.list_subscribe, - &self.list_unsubscribe, - ] { - if !addr.is_empty() { - return false; - } - } - - for str in [ - &self.subject, - &self.message_id, - &self.mime_version, - &self.content_description, - &self.content_id, - &self.content_transfer_encoding, - ] { - if str.is_some() { - return false; - } - } - - if self.date.is_some() || !self.others.is_empty() { - return false; - } - - for vec in [ - &self.comments, - &self.in_reply_to, - &self.keywords, - &self.received, - &self.references, - &self.resent_message_id, - &self.return_path, - ] { - if vec.is_some() { - return false; - } - } - - self.content_disposition.is_none() - && self.resent_date.is_none() - && self.content_type.is_none() - } +/// MIME Header field access trait +pub trait MimeHeaders<'x> { + /// Returns the Content-Description field + fn get_content_description(&self) -> Option<&str>; + /// Returns the Content-Disposition field + fn get_content_disposition(&self) -> Option<&ContentType>; + /// Returns the Content-ID field + fn get_content_id(&self) -> Option<&str>; + /// Returns the Content-Encoding field + fn get_content_transfer_encoding(&self) -> Option<&str>; + /// Returns the Content-Type field + fn get_content_type(&self) -> Option<&ContentType>; + /// Returns the Content-Language field + fn get_content_language(&self) -> &HeaderValue<'x>; + /// Returns the Content-Location field + fn get_content_location(&self) -> Option<&str>; } -impl<'x> MimeFieldGet<'x> for Message<'x> { - fn get_content_description(&self) -> Option<&Cow<'x, str>> { - self.header.content_description.as_ref() +impl<'x> MimeHeaders<'x> for Message<'x> { + fn get_content_description(&self) -> Option<&str> { + self.headers + .get(&HeaderName::ContentDescription) + .and_then(|header| header.as_text_ref()) } - fn get_content_disposition(&self) -> Option<&ContentType<'x>> { - self.header.content_disposition.as_ref() + fn get_content_disposition(&self) -> Option<&ContentType> { + self.headers + .get(&HeaderName::ContentDisposition) + .and_then(|header| header.as_content_type_ref()) } - fn get_content_id(&self) -> Option<&Cow<'x, str>> { - self.header.content_id.as_ref() + fn get_content_id(&self) -> Option<&str> { + self.headers + .get(&HeaderName::ContentId) + .and_then(|header| header.as_text_ref()) } - fn get_content_transfer_encoding(&self) -> Option<&Cow<'x, str>> { - self.header.content_transfer_encoding.as_ref() + fn get_content_transfer_encoding(&self) -> Option<&str> { + self.headers + .get(&HeaderName::ContentTransferEncoding) + .and_then(|header| header.as_text_ref()) } - fn get_content_type(&self) -> Option<&ContentType<'x>> { - self.header.content_type.as_ref() - } -} - -impl<'x> MimeFieldGet<'x> for MimeHeader<'x> { - fn get_content_description(&self) -> Option<&Cow<'x, str>> { - self.content_description.as_ref() + fn get_content_type(&self) -> Option<&ContentType> { + self.headers + .get(&HeaderName::ContentType) + .and_then(|header| header.as_content_type_ref()) } - fn get_content_disposition(&self) -> Option<&ContentType<'x>> { - self.content_disposition.as_ref() + fn get_content_language(&self) -> &HeaderValue<'x> { + self.headers + .get(&HeaderName::ContentLanguage) + .unwrap_or(&HeaderValue::Empty) } - fn get_content_id(&self) -> Option<&Cow<'x, str>> { - self.content_id.as_ref() - } - - fn get_content_transfer_encoding(&self) -> Option<&Cow<'x, str>> { - self.content_transfer_encoding.as_ref() - } - - fn get_content_type(&self) -> Option<&ContentType<'x>> { - self.content_type.as_ref() - } -} - -impl<'x> MimeFieldGet<'x> for MessageHeader<'x> { - fn get_content_description(&self) -> Option<&Cow<'x, str>> { - self.content_description.as_ref() - } - - fn get_content_disposition(&self) -> Option<&ContentType<'x>> { - self.content_disposition.as_ref() - } - - fn get_content_id(&self) -> Option<&Cow<'x, str>> { - self.content_id.as_ref() - } - - fn get_content_transfer_encoding(&self) -> Option<&Cow<'x, str>> { - self.content_transfer_encoding.as_ref() - } - - fn get_content_type(&self) -> Option<&ContentType<'x>> { - self.content_type.as_ref() + fn get_content_location(&self) -> Option<&str> { + self.headers + .get(&HeaderName::ContentLocation) + .and_then(|header| header.as_text_ref()) } } /// An inline Text or Binary body part. pub trait BodyPart<'x>: fmt::Display { - /// Returns the MIME Header of the part - fn get_header(&self) -> Option<&MimeHeader<'x>>; - /// Returns the body part's contents as a `u8` slice fn get_contents(&'x self) -> &'x [u8]; @@ -1095,10 +935,6 @@ pub trait BodyPart<'x>: fmt::Display { } impl<'x> BodyPart<'x> for TextPart<'x> { - fn get_header(&self) -> Option<&MimeHeader<'x>> { - self.header.as_ref() - } - fn get_contents(&'x self) -> &'x [u8] { self.contents.as_bytes() } @@ -1127,10 +963,6 @@ impl<'x> fmt::Display for TextPart<'x> { } impl<'x> BodyPart<'x> for BinaryPart<'x> { - fn get_header(&self) -> Option<&MimeHeader<'x>> { - self.header.as_ref() - } - fn get_contents(&'x self) -> &'x [u8] { self.contents.as_ref() } @@ -1158,6 +990,108 @@ impl<'x> fmt::Display for BinaryPart<'x> { } } +impl<'x> MimeHeaders<'x> for TextPart<'x> { + fn get_content_description(&self) -> Option<&str> { + self.headers.as_ref().and_then(|h| { + h.get(&HeaderName::ContentDescription) + .and_then(|header| header.as_text_ref()) + }) + } + + fn get_content_disposition(&self) -> Option<&ContentType> { + self.headers.as_ref().and_then(|h| { + h.get(&HeaderName::ContentDisposition) + .and_then(|header| header.as_content_type_ref()) + }) + } + + fn get_content_id(&self) -> Option<&str> { + self.headers.as_ref().and_then(|h| { + h.get(&HeaderName::ContentId) + .and_then(|header| header.as_text_ref()) + }) + } + + fn get_content_transfer_encoding(&self) -> Option<&str> { + self.headers.as_ref().and_then(|h| { + h.get(&HeaderName::ContentTransferEncoding) + .and_then(|header| header.as_text_ref()) + }) + } + + fn get_content_type(&self) -> Option<&ContentType> { + self.headers.as_ref().and_then(|h| { + h.get(&HeaderName::ContentType) + .and_then(|header| header.as_content_type_ref()) + }) + } + + fn get_content_language(&self) -> &HeaderValue<'x> { + self.headers.as_ref().map_or(&HeaderValue::Empty, |h| { + h.get(&HeaderName::ContentLanguage) + .unwrap_or(&HeaderValue::Empty) + }) + } + + fn get_content_location(&self) -> Option<&str> { + self.headers.as_ref().and_then(|h| { + h.get(&HeaderName::ContentLocation) + .and_then(|header| header.as_text_ref()) + }) + } +} + +impl<'x> MimeHeaders<'x> for BinaryPart<'x> { + fn get_content_description(&self) -> Option<&str> { + self.headers.as_ref().and_then(|h| { + h.get(&HeaderName::ContentDescription) + .and_then(|header| header.as_text_ref()) + }) + } + + fn get_content_disposition(&self) -> Option<&ContentType> { + self.headers.as_ref().and_then(|h| { + h.get(&HeaderName::ContentDisposition) + .and_then(|header| header.as_content_type_ref()) + }) + } + + fn get_content_id(&self) -> Option<&str> { + self.headers.as_ref().and_then(|h| { + h.get(&HeaderName::ContentId) + .and_then(|header| header.as_text_ref()) + }) + } + + fn get_content_transfer_encoding(&self) -> Option<&str> { + self.headers.as_ref().and_then(|h| { + h.get(&HeaderName::ContentTransferEncoding) + .and_then(|header| header.as_text_ref()) + }) + } + + fn get_content_type(&self) -> Option<&ContentType> { + self.headers.as_ref().and_then(|h| { + h.get(&HeaderName::ContentType) + .and_then(|header| header.as_content_type_ref()) + }) + } + + fn get_content_language(&self) -> &HeaderValue<'x> { + self.headers.as_ref().map_or(&HeaderValue::Empty, |h| { + h.get(&HeaderName::ContentLanguage) + .unwrap_or(&HeaderValue::Empty) + }) + } + + fn get_content_location(&self) -> Option<&str> { + self.headers.as_ref().and_then(|h| { + h.get(&HeaderName::ContentLocation) + .and_then(|header| header.as_text_ref()) + }) + } +} + #[doc(hidden)] pub struct BodyPartIterator<'x> { message: &'x Message<'x>, diff --git a/src/parsers/fields/address.rs b/src/parsers/fields/address.rs index d92a0cc..39ac15f 100644 --- a/src/parsers/fields/address.rs +++ b/src/parsers/fields/address.rs @@ -12,21 +12,10 @@ use std::borrow::Cow; use crate::{ - decoders::encoded_word::decode_rfc2047, parsers::message::MessageStream, Addr, Address, Group, + decoders::encoded_word::decode_rfc2047, parsers::message::MessageStream, Addr, Group, + HeaderValue, }; -impl<'x> Default for Address<'x> { - fn default() -> Self { - Address::Empty - } -} - -impl<'x> Address<'x> { - pub fn is_empty(&self) -> bool { - *self == Address::Empty - } -} - #[derive(PartialEq, Clone, Copy, Debug)] enum AddressState { Address, @@ -224,7 +213,7 @@ pub fn add_group(parser: &mut AddressParser) { }); } -pub fn parse_address<'x>(stream: &mut MessageStream<'x>) -> Address<'x> { +pub fn parse_address<'x>(stream: &mut MessageStream<'x>) -> HeaderValue<'x> { let mut parser = AddressParser { token_start: 0, token_end: 0, @@ -394,18 +383,18 @@ pub fn parse_address<'x>(stream: &mut MessageStream<'x>) -> Address<'x> { if parser.group_name.is_some() || !parser.result.is_empty() { add_group(&mut parser); if parser.result.len() > 1 { - Address::GroupList(parser.result) + HeaderValue::GroupList(parser.result) } else { - Address::Group(parser.result.pop().unwrap()) + HeaderValue::Group(parser.result.pop().unwrap()) } } else if !parser.addresses.is_empty() { if parser.addresses.len() > 1 { - Address::AddressList(parser.addresses) + HeaderValue::AddressList(parser.addresses) } else { - Address::Address(parser.addresses.pop().unwrap()) + HeaderValue::Address(parser.addresses.pop().unwrap()) } } else { - Address::Empty + HeaderValue::Empty } } @@ -936,7 +925,7 @@ mod tests { println!("Testiong {}", input.0); let str = input.0.to_string(); let result = parse_address(&mut MessageStream::new(str.as_bytes())); - let expected: Address = serde_yaml::from_str(input.1).unwrap_or(Address::Empty); + let expected: HeaderValue = serde_yaml::from_str(input.1).unwrap_or(HeaderValue::Empty); /*if input.0.len() >= 70 { println!( diff --git a/src/parsers/fields/content_type.rs b/src/parsers/fields/content_type.rs index 05f5031..b936eae 100644 --- a/src/parsers/fields/content_type.rs +++ b/src/parsers/fields/content_type.rs @@ -17,7 +17,7 @@ use std::{ use crate::{ decoders::{charsets::map::get_charset_decoder, encoded_word::decode_rfc2047, hex::decode_hex}, parsers::message::MessageStream, - ContentType, + ContentType, HeaderValue, }; #[derive(Clone, Copy, PartialEq, Debug)] @@ -244,7 +244,7 @@ fn merge_continuations(parser: &mut ContentTypeParser) { } } -pub fn parse_content_type<'x>(stream: &mut MessageStream<'x>) -> Option> { +pub fn parse_content_type<'x>(stream: &mut MessageStream<'x>) -> HeaderValue<'x> { let mut parser = ContentTypeParser { state: ContentState::Type, state_stack: Vec::new(), @@ -327,7 +327,7 @@ pub fn parse_content_type<'x>(stream: &mut MessageStream<'x>) -> Option(stream: &mut MessageStream<'x>) -> Option(stream: &mut MessageStream<'x>) -> Option = serde_yaml::from_str(input.1).unwrap_or(None); + let expected: HeaderValue = serde_yaml::from_str(input.1).unwrap_or(HeaderValue::Empty); /* if input.0.len() >= 70 { @@ -1369,7 +1558,7 @@ mod tests { expected, "Failed for '{:?}', result was:\n{}", input.0, - serde_yaml::to_string(result.as_ref().unwrap()).unwrap() + serde_yaml::to_string(&result).unwrap() ); } } diff --git a/src/parsers/fields/date.rs b/src/parsers/fields/date.rs index 5880259..14e8065 100644 --- a/src/parsers/fields/date.rs +++ b/src/parsers/fields/date.rs @@ -11,7 +11,7 @@ use std::fmt; -use crate::{parsers::message::MessageStream, DateTime}; +use crate::{parsers::message::MessageStream, DateTime, HeaderValue}; impl DateTime { /// Returns an ISO-8601 representation of the parsed RFC5322 datetime field @@ -37,7 +37,7 @@ impl fmt::Display for DateTime { } } -pub fn parse_date(stream: &mut MessageStream) -> Option { +pub fn parse_date<'x>(stream: &mut MessageStream<'x>) -> HeaderValue<'x> { let mut pos = 0; let mut parts = [0u32; 7]; let mut parts_sizes = [ @@ -151,7 +151,7 @@ pub fn parse_date(stream: &mut MessageStream) -> Option { } if pos >= 6 { - Some(DateTime { + HeaderValue::DateTime(DateTime { year: if (1..=99).contains(&parts[2]) { parts[2] + 1900 } else { @@ -171,7 +171,7 @@ pub fn parse_date(stream: &mut MessageStream) -> Option { tz_before_gmt: !is_plus, }) } else { - None + HeaderValue::Empty } } @@ -195,7 +195,10 @@ pub static MONTH_MAP: &[u8; 31] = &[ #[cfg(test)] mod tests { - use crate::parsers::{fields::date::parse_date, message::MessageStream}; + use crate::{ + parsers::{fields::date::parse_date, message::MessageStream}, + HeaderValue, + }; #[test] fn parse_dates() { @@ -262,14 +265,15 @@ mod tests { for input in inputs { let str = input.0.to_string(); match parse_date(&mut MessageStream::new(str.as_bytes())) { - Some(date) => { + HeaderValue::DateTime(date) => { //println!("{} -> {}", input.0.escape_debug(), date.to_iso8601()); assert_eq!(input.1, date.to_iso8601()); } - None => { + HeaderValue::Empty => { //println!("{} -> None", input.0.escape_debug()); assert!(input.1.is_empty()); } + _ => panic!("Unexpected result"), } } } diff --git a/src/parsers/fields/id.rs b/src/parsers/fields/id.rs index 7d3ff5a..6f4bc51 100644 --- a/src/parsers/fields/id.rs +++ b/src/parsers/fields/id.rs @@ -9,11 +9,9 @@ * except according to those terms. */ -use std::borrow::Cow; +use crate::{parsers::message::MessageStream, HeaderValue}; -use crate::parsers::message::MessageStream; - -pub fn parse_id<'x>(stream: &mut MessageStream<'x>) -> Option>> { +pub fn parse_id<'x>(stream: &mut MessageStream<'x>) -> HeaderValue<'x> { let mut token_start: usize = 0; let mut token_end: usize = 0; let mut is_id_part = false; @@ -31,7 +29,11 @@ pub fn parse_id<'x>(stream: &mut MessageStream<'x>) -> Option>> continue; } _ => { - return if !ids.is_empty() { Some(ids) } else { None }; + return match ids.len() { + 1 => HeaderValue::Text(ids.pop().unwrap()), + 0 => HeaderValue::Empty, + _ => HeaderValue::TextList(ids), + }; } }, b'<' => { @@ -60,13 +62,14 @@ pub fn parse_id<'x>(stream: &mut MessageStream<'x>) -> Option>> } } - None + HeaderValue::Empty } #[cfg(test)] mod tests { use crate::parsers::fields::id::parse_id; use crate::parsers::message::MessageStream; + use crate::HeaderValue; #[test] fn parse_message_ids() { @@ -103,12 +106,16 @@ mod tests { for input in inputs { let str = input.0.to_string(); - assert_eq!( - input.1, - parse_id(&mut MessageStream::new(str.as_bytes())).unwrap(), - "Failed to parse '{:?}'", - input.0 - ); + match parse_id(&mut MessageStream::new(str.as_bytes())) { + HeaderValue::TextList(ids) => { + assert_eq!(ids, input.1, "Failed to parse '{:?}'", input.0); + } + HeaderValue::Text(id) => { + assert!(input.1.len() == 1, "Failed to parse '{:?}'", input.0); + assert_eq!(id, input.1[0], "Failed to parse '{:?}'", input.0); + } + _ => panic!("Unexpected result"), + } } } } diff --git a/src/parsers/fields/list.rs b/src/parsers/fields/list.rs index 87f30ae..80b6a53 100644 --- a/src/parsers/fields/list.rs +++ b/src/parsers/fields/list.rs @@ -11,7 +11,7 @@ use std::borrow::Cow; -use crate::{decoders::encoded_word::decode_rfc2047, parsers::message::MessageStream}; +use crate::{decoders::encoded_word::decode_rfc2047, parsers::message::MessageStream, HeaderValue}; struct ListParser<'x> { token_start: usize, @@ -51,7 +51,7 @@ fn add_tokens_to_list(parser: &mut ListParser) { } } -pub fn parse_comma_separared<'x>(stream: &mut MessageStream<'x>) -> Option>> { +pub fn parse_comma_separared<'x>(stream: &mut MessageStream<'x>) -> HeaderValue<'x> { let mut parser = ListParser { token_start: 0, token_end: 0, @@ -80,10 +80,10 @@ pub fn parse_comma_separared<'x>(stream: &mut MessageStream<'x>) -> Option { add_tokens_to_list(&mut parser); - return if !parser.list.is_empty() { - parser.list.into() - } else { - None + return match parser.list.len() { + 1 => HeaderValue::Text(parser.list.pop().unwrap()), + 0 => HeaderValue::Empty, + _ => HeaderValue::TextList(parser.list), }; } } @@ -123,13 +123,14 @@ pub fn parse_comma_separared<'x>(stream: &mut MessageStream<'x>) -> Option { + assert_eq!(ids, input.1, "Failed to parse '{:?}'", input.0); + } + HeaderValue::Text(id) => { + assert!(input.1.len() == 1, "Failed to parse '{:?}'", input.0); + assert_eq!(id, input.1[0], "Failed to parse '{:?}'", input.0); + } + _ => panic!("Unexpected result"), + } } } } diff --git a/src/parsers/fields/mod.rs b/src/parsers/fields/mod.rs index 0940119..0d789f8 100644 --- a/src/parsers/fields/mod.rs +++ b/src/parsers/fields/mod.rs @@ -9,20 +9,6 @@ * except according to those terms. */ -use std::borrow::Cow; - -use crate::{Address, DateTime, MessageHeader, MimeFieldGet, MimeHeader}; - -use self::{ - address::parse_address, - id::parse_id, - list::parse_comma_separared, - raw::{parse_and_ignore, parse_raw}, - unstructured::parse_unstructured, -}; - -use super::message::MessageStream; - pub mod address; pub mod content_type; pub mod date; @@ -30,558 +16,3 @@ pub mod id; pub mod list; pub mod raw; pub mod unstructured; - -pub trait MessageField<'x>: FieldSet<'x> + MimeFieldGet<'x> {} -impl<'x, T: FieldSet<'x> + MimeFieldGet<'x>> MessageField<'x> for T {} - -pub trait FieldSet<'x> { - fn set_date(&mut self, stream: &mut MessageStream<'x>); - fn set_sender(&mut self, stream: &mut MessageStream<'x>); - fn set_received(&mut self, stream: &mut MessageStream<'x>); - fn set_references(&mut self, stream: &mut MessageStream<'x>); - fn set_cc(&mut self, stream: &mut MessageStream<'x>); - fn set_comments(&mut self, stream: &mut MessageStream<'x>); - fn set_resent_cc(&mut self, stream: &mut MessageStream<'x>); - fn set_content_id(&mut self, stream: &mut MessageStream<'x>); - fn set_resent_message_id(&mut self, stream: &mut MessageStream<'x>); - fn set_reply_to(&mut self, stream: &mut MessageStream<'x>); - fn set_resent_to(&mut self, stream: &mut MessageStream<'x>); - fn set_resent_bcc(&mut self, stream: &mut MessageStream<'x>); - fn set_subject(&mut self, stream: &mut MessageStream<'x>); - fn set_keywords(&mut self, stream: &mut MessageStream<'x>); - fn set_list_help(&mut self, stream: &mut MessageStream<'x>); - fn set_list_id(&mut self, stream: &mut MessageStream<'x>); - fn set_list_owner(&mut self, stream: &mut MessageStream<'x>); - fn set_resent_date(&mut self, stream: &mut MessageStream<'x>); - fn set_to(&mut self, stream: &mut MessageStream<'x>); - fn set_bcc(&mut self, stream: &mut MessageStream<'x>); - fn set_from(&mut self, stream: &mut MessageStream<'x>); - fn set_content_transfer_encoding(&mut self, stream: &mut MessageStream<'x>); - fn set_return_path(&mut self, stream: &mut MessageStream<'x>); - fn set_list_archive(&mut self, stream: &mut MessageStream<'x>); - fn set_resent_sender(&mut self, stream: &mut MessageStream<'x>); - fn set_list_subscribe(&mut self, stream: &mut MessageStream<'x>); - fn set_message_id(&mut self, stream: &mut MessageStream<'x>); - fn set_content_type(&mut self, stream: &mut MessageStream<'x>); - fn set_list_post(&mut self, stream: &mut MessageStream<'x>); - fn set_in_reply_to(&mut self, stream: &mut MessageStream<'x>); - fn set_content_description(&mut self, stream: &mut MessageStream<'x>); - fn set_resent_from(&mut self, stream: &mut MessageStream<'x>); - fn set_content_disposition(&mut self, stream: &mut MessageStream<'x>); - fn set_list_unsubscribe(&mut self, stream: &mut MessageStream<'x>); - fn set_mime_version(&mut self, stream: &mut MessageStream<'x>); - fn set_unsupported(&mut self, stream: &mut MessageStream<'x>, name: &'x [u8]); -} - -impl<'x> FieldSet<'x> for MessageHeader<'x> { - fn set_date(&mut self, stream: &mut MessageStream<'x>) { - self.date = self::date::parse_date(stream); - } - - fn set_sender(&mut self, stream: &mut MessageStream<'x>) { - self.sender = parse_address(stream); - } - - fn set_received(&mut self, stream: &mut MessageStream<'x>) { - append_line(&mut self.received, parse_raw(stream)); - } - - fn set_references(&mut self, stream: &mut MessageStream<'x>) { - self.references = parse_id(stream); - } - - fn set_cc(&mut self, stream: &mut MessageStream<'x>) { - self.cc = parse_address(stream); - } - - fn set_comments(&mut self, stream: &mut MessageStream<'x>) { - append_line(&mut self.comments, parse_unstructured(stream)); - } - - fn set_resent_cc(&mut self, stream: &mut MessageStream<'x>) { - append_address_line(&mut self.resent_cc, parse_address(stream)); - } - - fn set_resent_message_id(&mut self, stream: &mut MessageStream<'x>) { - append_line_many(&mut self.resent_message_id, parse_id(stream)); - } - - fn set_reply_to(&mut self, stream: &mut MessageStream<'x>) { - self.reply_to = parse_address(stream); - } - - fn set_resent_to(&mut self, stream: &mut MessageStream<'x>) { - append_address_line(&mut self.resent_to, parse_address(stream)); - } - - fn set_resent_bcc(&mut self, stream: &mut MessageStream<'x>) { - append_address_line(&mut self.resent_bcc, parse_address(stream)); - } - - fn set_subject(&mut self, stream: &mut MessageStream<'x>) { - self.subject = parse_unstructured(stream); - } - - fn set_keywords(&mut self, stream: &mut MessageStream<'x>) { - append_line_many(&mut self.keywords, parse_comma_separared(stream)); - } - - fn set_list_help(&mut self, stream: &mut MessageStream<'x>) { - self.list_help = parse_address(stream); - } - - fn set_list_id(&mut self, stream: &mut MessageStream<'x>) { - self.list_id = parse_address(stream); - } - - fn set_list_owner(&mut self, stream: &mut MessageStream<'x>) { - self.list_owner = parse_address(stream); - } - - fn set_resent_date(&mut self, stream: &mut MessageStream<'x>) { - append_date_line(&mut self.resent_date, self::date::parse_date(stream)); - } - - fn set_to(&mut self, stream: &mut MessageStream<'x>) { - self.to = parse_address(stream); - } - - fn set_bcc(&mut self, stream: &mut MessageStream<'x>) { - self.bcc = parse_address(stream); - } - - fn set_from(&mut self, stream: &mut MessageStream<'x>) { - self.from = parse_address(stream); - } - - fn set_return_path(&mut self, stream: &mut MessageStream<'x>) { - append_line_many(&mut self.return_path, parse_id(stream)); - } - - fn set_list_archive(&mut self, stream: &mut MessageStream<'x>) { - self.list_archive = parse_address(stream); - } - - fn set_resent_sender(&mut self, stream: &mut MessageStream<'x>) { - append_address_line(&mut self.resent_sender, parse_address(stream)); - } - - fn set_list_subscribe(&mut self, stream: &mut MessageStream<'x>) { - self.list_subscribe = parse_address(stream); - } - - fn set_message_id(&mut self, stream: &mut MessageStream<'x>) { - self.message_id = parse_id(stream).map(|mut v| v.pop().unwrap()); - } - - fn set_list_post(&mut self, stream: &mut MessageStream<'x>) { - self.list_post = parse_address(stream); - } - - fn set_in_reply_to(&mut self, stream: &mut MessageStream<'x>) { - self.reply_to = parse_address(stream); - } - - fn set_resent_from(&mut self, stream: &mut MessageStream<'x>) { - append_address_line(&mut self.resent_from, parse_address(stream)); - } - - fn set_list_unsubscribe(&mut self, stream: &mut MessageStream<'x>) { - self.list_unsubscribe = parse_address(stream); - } - - fn set_mime_version(&mut self, stream: &mut MessageStream<'x>) { - self.mime_version = parse_raw(stream); - } - - fn set_unsupported(&mut self, stream: &mut MessageStream<'x>, name: &'x [u8]) { - if let Ok(name) = std::str::from_utf8(name) { - if let Some(value) = parse_unstructured(stream) { - if let Some(arr) = self.others.get_mut(name) { - arr.push(value); - } else { - self.others.insert(name, vec![value]); - } - } - } - } - - fn set_content_id(&mut self, stream: &mut MessageStream<'x>) { - self.content_id = parse_id(stream).map(|mut v| v.pop().unwrap()); - } - - fn set_content_transfer_encoding(&mut self, stream: &mut MessageStream<'x>) { - self.content_transfer_encoding = parse_unstructured(stream); - } - - fn set_content_type(&mut self, stream: &mut MessageStream<'x>) { - self.content_type = self::content_type::parse_content_type(stream); - } - - fn set_content_description(&mut self, stream: &mut MessageStream<'x>) { - self.content_description = parse_unstructured(stream); - } - - fn set_content_disposition(&mut self, stream: &mut MessageStream<'x>) { - self.content_disposition = self::content_type::parse_content_type(stream); - } -} - -impl<'x> FieldSet<'x> for MimeHeader<'x> { - fn set_date(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_sender(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_received(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_references(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_cc(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_comments(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_resent_cc(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_resent_message_id(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_reply_to(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_resent_to(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_resent_bcc(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_subject(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_keywords(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_list_help(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_list_id(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_list_owner(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_resent_date(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_to(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_bcc(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_from(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_return_path(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_list_archive(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_resent_sender(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_list_subscribe(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_message_id(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_list_post(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_in_reply_to(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_resent_from(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_list_unsubscribe(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_mime_version(&mut self, stream: &mut MessageStream<'x>) { - parse_and_ignore(stream); - } - - fn set_unsupported(&mut self, stream: &mut MessageStream<'x>, _name: &'x [u8]) { - parse_and_ignore(stream); - } - - fn set_content_id(&mut self, stream: &mut MessageStream<'x>) { - self.content_id = parse_id(stream).map(|mut v| v.pop().unwrap()); - } - - fn set_content_transfer_encoding(&mut self, stream: &mut MessageStream<'x>) { - self.content_transfer_encoding = parse_unstructured(stream); - } - - fn set_content_type(&mut self, stream: &mut MessageStream<'x>) { - self.content_type = self::content_type::parse_content_type(stream); - } - - fn set_content_description(&mut self, stream: &mut MessageStream<'x>) { - self.content_description = parse_unstructured(stream); - } - - fn set_content_disposition(&mut self, stream: &mut MessageStream<'x>) { - self.content_disposition = self::content_type::parse_content_type(stream); - } -} - -pub fn parse_date<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_date(stream); -} - -pub fn parse_sender<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_sender(stream); -} - -pub fn parse_received<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_received(stream); -} - -pub fn parse_references<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_references(stream); -} - -pub fn parse_cc<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_cc(stream); -} - -pub fn parse_comments<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_comments(stream); -} - -pub fn parse_resent_cc<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_resent_cc(stream); -} - -pub fn parse_content_id<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_content_id(stream); -} - -pub fn parse_resent_message_id<'x>( - header: &mut dyn MessageField<'x>, - stream: &mut MessageStream<'x>, -) { - header.set_resent_message_id(stream); -} - -pub fn parse_reply_to<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_reply_to(stream); -} - -pub fn parse_resent_to<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_resent_to(stream); -} - -pub fn parse_resent_bcc<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_resent_bcc(stream); -} - -pub fn parse_subject<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_subject(stream); -} - -pub fn parse_keywords<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_keywords(stream); -} - -pub fn parse_list_help<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_list_help(stream); -} - -pub fn parse_list_id<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_list_id(stream); -} - -pub fn parse_list_owner<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_list_owner(stream); -} - -pub fn parse_resent_date<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_resent_date(stream); -} - -pub fn parse_to<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_to(stream); -} - -pub fn parse_bcc<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_bcc(stream); -} - -pub fn parse_from<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_from(stream); -} - -pub fn parse_content_transfer_encoding<'x>( - header: &mut dyn MessageField<'x>, - stream: &mut MessageStream<'x>, -) { - header.set_content_transfer_encoding(stream); -} - -pub fn parse_return_path<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_return_path(stream); -} - -pub fn parse_list_archive<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_list_archive(stream); -} - -pub fn parse_resent_sender<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_resent_sender(stream); -} - -pub fn parse_list_subscribe<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_list_subscribe(stream); -} - -pub fn parse_message_id<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_message_id(stream); -} - -pub fn parse_content_type<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_content_type(stream); -} - -pub fn parse_list_post<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_list_post(stream); -} - -pub fn parse_in_reply_to<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_in_reply_to(stream); -} - -pub fn parse_content_description<'x>( - header: &mut dyn MessageField<'x>, - stream: &mut MessageStream<'x>, -) { - header.set_content_description(stream); -} - -pub fn parse_resent_from<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_resent_from(stream); -} - -pub fn parse_content_disposition<'x>( - header: &mut dyn MessageField<'x>, - stream: &mut MessageStream<'x>, -) { - header.set_content_disposition(stream); -} - -pub fn parse_list_unsubscribe<'x>( - header: &mut dyn MessageField<'x>, - stream: &mut MessageStream<'x>, -) { - header.set_list_unsubscribe(stream); -} - -pub fn parse_mime_version<'x>(header: &mut dyn MessageField<'x>, stream: &mut MessageStream<'x>) { - header.set_mime_version(stream); -} - -fn append_address_line<'x>(value: &mut Address<'x>, new_value: Address<'x>) { - if new_value != Address::Empty { - match value { - Address::Collection(ref mut arr) => { - arr.push(new_value); - } - Address::Empty => *value = new_value, - _ => { - *value = Address::Collection(vec![std::mem::take(value), new_value]); - } - } - } -} - -fn append_date_line(value: &mut Option>, new_value: Option) { - if let Some(new_value) = new_value { - if let Some(value) = value { - value.push(new_value); - } else { - *value = Some(vec![new_value]); - } - } -} - -fn append_line<'x>(value: &mut Option>>, new_value: Option>) { - if let Some(new_value) = new_value { - if let Some(value) = value { - value.push(new_value); - } else { - *value = Some(vec![new_value]); - } - } -} - -fn append_line_many<'x>( - value: &mut Option>>, - new_value: Option>>, -) { - if let Some(mut new_value) = new_value { - if let Some(value) = value { - value.append(&mut new_value); - } else { - *value = Some(new_value); - } - } -} - -pub fn parse_no_op<'x>(_header: &mut dyn MessageField<'x>, _stream: &mut MessageStream<'x>) {} - -pub fn parse_unsupported<'x>( - header: &mut dyn MessageField<'x>, - stream: &mut MessageStream<'x>, - - name: &'x [u8], -) { - header.set_unsupported(stream, name); -} diff --git a/src/parsers/fields/raw.rs b/src/parsers/fields/raw.rs index 31ed7f8..c5e9f98 100644 --- a/src/parsers/fields/raw.rs +++ b/src/parsers/fields/raw.rs @@ -9,11 +9,9 @@ * except according to those terms. */ -use std::borrow::Cow; +use crate::{parsers::message::MessageStream, HeaderValue}; -use crate::parsers::message::MessageStream; - -pub fn parse_raw<'x>(stream: &mut MessageStream<'x>) -> Option> { +pub fn parse_raw<'x>(stream: &mut MessageStream<'x>) -> HeaderValue<'x> { let mut token_start: usize = 0; let mut token_end: usize = 0; @@ -30,9 +28,11 @@ pub fn parse_raw<'x>(stream: &mut MessageStream<'x>) -> Option> { } _ => { return if token_start > 0 { - String::from_utf8_lossy(&stream.data[token_start - 1..token_end]).into() + HeaderValue::Text(String::from_utf8_lossy( + &stream.data[token_start - 1..token_end], + )) } else { - None + HeaderValue::Empty }; } }, @@ -47,7 +47,7 @@ pub fn parse_raw<'x>(stream: &mut MessageStream<'x>) -> Option> { token_end = stream.pos; } - None + HeaderValue::Empty } pub fn parse_and_ignore(stream: &mut MessageStream) { @@ -96,7 +96,7 @@ mod tests { for input in inputs { let str = input.0.to_string(); assert_eq!( - parse_raw(&mut MessageStream::new(str.as_bytes())).unwrap(), + parse_raw(&mut MessageStream::new(str.as_bytes())).unwrap_text(), input.1, "Failed for '{:?}'", input.0 diff --git a/src/parsers/fields/unstructured.rs b/src/parsers/fields/unstructured.rs index 04c138e..203269d 100644 --- a/src/parsers/fields/unstructured.rs +++ b/src/parsers/fields/unstructured.rs @@ -11,7 +11,7 @@ use std::borrow::Cow; -use crate::{decoders::encoded_word::decode_rfc2047, parsers::message::MessageStream}; +use crate::{decoders::encoded_word::decode_rfc2047, parsers::message::MessageStream, HeaderValue}; struct UnstructuredParser<'x> { token_start: usize, token_end: usize, @@ -37,7 +37,7 @@ fn add_token<'x>(parser: &mut UnstructuredParser<'x>, stream: &MessageStream<'x> } } -pub fn parse_unstructured<'x>(stream: &mut MessageStream<'x>) -> Option> { +pub fn parse_unstructured<'x>(stream: &mut MessageStream<'x>) -> HeaderValue<'x> { let mut parser = UnstructuredParser { token_start: 0, token_end: 0, @@ -64,9 +64,9 @@ pub fn parse_unstructured<'x>(stream: &mut MessageStream<'x>) -> Option { return match parser.tokens.len() { - 1 => parser.tokens.pop().unwrap().into(), - 0 => None, - _ => Some(parser.tokens.concat().into()), + 1 => HeaderValue::Text(parser.tokens.pop().unwrap()), + 0 => HeaderValue::Empty, + _ => HeaderValue::Text(parser.tokens.concat().into()), }; } } @@ -101,7 +101,7 @@ pub fn parse_unstructured<'x>(stream: &mut MessageStream<'x>) -> Option MessageHeader<'x> { - pub fn new() -> MessageHeader<'x> { - MessageHeader { - ..Default::default() - } - } -} - -impl<'x> MimeHeader<'x> { - pub fn new() -> MimeHeader<'x> { - MimeHeader { - ..Default::default() - } - } - - pub fn clear(&mut self) { - self.content_description = None; - self.content_disposition = None; - self.content_id = None; - self.content_transfer_encoding = None; - self.content_type = None; - } - - pub fn is_empty(&self) -> bool { - self.content_description.is_none() - && self.content_disposition.is_none() - && self.content_id.is_none() - && self.content_transfer_encoding.is_none() - && self.content_type.is_none() - } -} - +#[derive(Debug, PartialEq)] pub enum HeaderParserResult<'x> { - Supported(fn(&mut dyn MessageField<'x>, &mut MessageStream<'x>)), + Supported(HeaderName), Unsupported(&'x [u8]), Lf, Eof, } -pub fn parse_headers<'x>( - header: &mut dyn MessageField<'x>, - stream: &mut MessageStream<'x>, -) -> bool { +pub fn parse_headers<'x>(headers: &mut Headers<'x>, stream: &mut MessageStream<'x>) -> bool { loop { - match parse_header_name(stream) { - HeaderParserResult::Supported(fnc) => fnc(header, stream), - HeaderParserResult::Unsupported(name) => parse_unsupported(header, stream, name), + let (bytes_read, result) = parse_header_name(&stream.data[stream.pos..]); + stream.pos += bytes_read; + + match result { + HeaderParserResult::Supported(name) => { + let (is_many, parser) = HDR_PARSER[name as usize]; + + let value = parser(stream); + if !value.is_empty() { + if is_many { + match headers.entry(name) { + Entry::Occupied(mut e) => { + if let HeaderValue::Collection(col) = e.get_mut() { + col.push(value); + } else { + let old_value = e.remove(); + headers.insert( + name, + HeaderValue::Collection(vec![old_value, value]), + ); + } + } + Entry::Vacant(e) => { + e.insert(value); + } + } + } else { + headers.insert(name, value); + } + } + } + HeaderParserResult::Unsupported(_name) => parse_and_ignore(stream), HeaderParserResult::Lf => return true, HeaderParserResult::Eof => return false, } } } -pub fn parse_header_name<'x>(stream: &mut MessageStream<'x>) -> HeaderParserResult<'x> { +pub fn parse_header_name(data: &[u8]) -> (usize, HeaderParserResult) { let mut token_start: usize = 0; let mut token_end: usize = 0; let mut token_len: usize = 0; let mut token_hash: usize = 0; let mut last_ch: u8 = 0; + let mut bytes_read: usize = 0; - for ch in stream.data[stream.pos..].iter() { - stream.pos += 1; + for ch in data.iter() { + bytes_read += 1; match ch { b':' => { if token_start != 0 { - let field = &stream.data[token_start - 1..token_end]; + let field = &data[token_start - 1..token_end]; if (2..=25).contains(&token_len) { token_hash += token_len + HDR_HASH[last_ch.to_ascii_lowercase() as usize] as usize; - if (4..=61).contains(&token_hash) { + if (4..=72).contains(&token_hash) { let token_hash = token_hash - 4; if field.eq_ignore_ascii_case(HDR_NAMES[token_hash]) { - return HeaderParserResult::Supported(HDR_FNCS[token_hash]); + return ( + bytes_read, + HeaderParserResult::Supported(HDR_MAP[token_hash]), + ); } } } - return HeaderParserResult::Unsupported(field); + return (bytes_read, HeaderParserResult::Unsupported(field)); } } b'\n' => { - stream.pos -= 1; - return HeaderParserResult::Lf; + return (bytes_read - 1, HeaderParserResult::Lf); } _ => { if !(*ch).is_ascii_whitespace() { if token_start == 0 { - token_start = stream.pos; + token_start = bytes_read; token_end = token_start; } else { - token_end = stream.pos; + token_end = bytes_read; last_ch = *ch; } @@ -122,27 +130,45 @@ pub fn parse_header_name<'x>(stream: &mut MessageStream<'x>) -> HeaderParserResu } } - HeaderParserResult::Eof + (bytes_read, HeaderParserResult::Eof) } +/*fn set_unsupported(&mut self, stream: &mut MessageStream<'x>, name: &'x [u8]) { + if let Ok(name) = std::str::from_utf8(name) { + let value = parse_unstructured(stream); + if !value.is_empty() { + match self.others.entry(name) { + Entry::Occupied(mut e) => { + if let HeaderValue::Collection(col) = e.get_mut() { + col.push(value); + } else { + let old_value = e.remove(); + self.others.insert(name,HeaderValue::Collection(vec![old_value, value])); + } + }, + Entry::Vacant(e) => {e.insert(value);}, + } + } + } +}*/ + #[cfg(test)] mod tests { - use crate::parsers::{ - fields::{parse_from, parse_mime_version, parse_received, parse_subject}, - header::parse_header_name, - message::MessageStream, - }; + use crate::{parsers::header::parse_header_name, HeaderName}; use super::HeaderParserResult; #[test] fn header_name_parse() { let inputs = [ - ("From: ", HeaderParserResult::Supported(parse_from)), - ("receiVED: ", HeaderParserResult::Supported(parse_received)), + ("From: ", HeaderParserResult::Supported(HeaderName::From)), + ( + "receiVED: ", + HeaderParserResult::Supported(HeaderName::Received), + ), ( " subject : ", - HeaderParserResult::Supported(parse_subject), + HeaderParserResult::Supported(HeaderName::Subject), ), ( "X-Custom-Field : ", @@ -155,166 +181,217 @@ mod tests { ), ( "MIME-version : ", - HeaderParserResult::Supported(parse_mime_version), + HeaderParserResult::Supported(HeaderName::MimeVersion), ), ]; for input in inputs { let str = input.0.to_string(); - match parse_header_name(&mut MessageStream::new(str.as_bytes())) { - HeaderParserResult::Supported(f) => { - if let HeaderParserResult::Supported(val) = input.1 { - if f as usize == val as usize { - continue; - } - } - } - HeaderParserResult::Unsupported(name) => { - if let HeaderParserResult::Unsupported(val) = input.1 { - if name == val { - continue; - } - } - } - _ => panic!("Eof/Lf for '{:?}'", input.0), - } - panic!("Failed to parse '{:?}'", input.0) + let (_, result) = parse_header_name(str.as_bytes()); + assert_eq!(input.1, result, "Failed to parse '{:?}'", input.0); } } } +#[allow(clippy::type_complexity)] +static HDR_PARSER: &[( + bool, + for<'x, 'y> fn(&mut MessageStream<'x>) -> HeaderValue<'x>, +)] = &[ + (false, parse_unstructured), // Subject = 0, + (false, parse_address), // From = 1, + (false, parse_address), // To = 2, + (false, parse_address), // Cc = 3, + (false, parse_date), // Date = 4, + (false, parse_address), // Bcc = 5, + (false, parse_address), // ReplyTo = 6, + (false, parse_address), // Sender = 7, + (true, parse_unstructured), // Comments = 8, + (false, parse_address), // InReplyTo = 9, + (true, parse_comma_separared), // Keywords = 10, + (true, parse_raw), // Received = 11, + (false, parse_id), // MessageId = 12, + (true, parse_id), // References = 13, (RFC 5322 recommends One) + (false, parse_id), // ReturnPath = 14, + (false, parse_raw), // MimeVersion = 15, + (false, parse_unstructured), // ContentDescription = 16, + (false, parse_id), // ContentId = 17, + (false, parse_comma_separared), // ContentLanguage = 18 + (false, parse_unstructured), // ContentLocation = 19 + (false, parse_unstructured), // ContentTransferEncoding = 20, + (false, parse_content_type), // ContentType = 21, + (false, parse_content_type), // ContentDisposition = 22, + (true, parse_address), // ResentTo = 23, + (true, parse_address), // ResentFrom = 24, + (true, parse_address), // ResentBcc = 25, + (true, parse_address), // ResentCc = 26, + (true, parse_address), // ResentSender = 27, + (true, parse_date), // ResentDate = 28, + (true, parse_id), // ResentMessageId = 29, + (false, parse_address), // ListArchive = 30, + (false, parse_address), // ListHelp = 31, + (false, parse_address), // ListId = 32, + (false, parse_address), // ListOwner = 33, + (false, parse_address), // ListPost = 34, + (false, parse_address), // ListSubscribe = 35, + (false, parse_address), // ListUnsubscribe = 36, + (false, parse_raw), // Unsupported = 37, +]; + static HDR_HASH: &[u8] = &[ - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 15, 5, 0, 0, 30, 5, 5, 15, 62, 20, 15, 20, 5, 30, 25, 62, 0, 0, 0, 62, 62, 62, 62, 10, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 0, 20, 5, 0, 0, 25, 0, 5, 20, 73, 25, 25, 30, 10, 10, 5, 73, 0, 0, 15, 73, 73, 73, 73, 20, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, ]; -static HDR_FNCS: &[for<'x, 'y> fn(&mut dyn MessageField<'x>, &mut MessageStream<'x>); 58] = &[ - super::fields::parse_date, - super::fields::parse_no_op, - super::fields::parse_sender, - super::fields::parse_subject, - super::fields::parse_received, - super::fields::parse_no_op, - super::fields::parse_references, - super::fields::parse_resent_date, - super::fields::parse_cc, - super::fields::parse_comments, - super::fields::parse_resent_cc, - super::fields::parse_content_id, - super::fields::parse_return_path, - super::fields::parse_resent_message_id, - super::fields::parse_resent_sender, - super::fields::parse_no_op, - super::fields::parse_resent_bcc, - super::fields::parse_no_op, - super::fields::parse_list_id, - super::fields::parse_bcc, - super::fields::parse_list_post, - super::fields::parse_list_owner, - super::fields::parse_no_op, - super::fields::parse_content_type, - super::fields::parse_keywords, - super::fields::parse_content_description, - super::fields::parse_message_id, - super::fields::parse_no_op, - super::fields::parse_to, - super::fields::parse_no_op, - super::fields::parse_list_subscribe, - super::fields::parse_content_transfer_encoding, - super::fields::parse_no_op, - super::fields::parse_no_op, - super::fields::parse_reply_to, - super::fields::parse_resent_to, - super::fields::parse_no_op, - super::fields::parse_no_op, - super::fields::parse_list_archive, - super::fields::parse_no_op, - super::fields::parse_content_disposition, - super::fields::parse_no_op, - super::fields::parse_list_unsubscribe, - super::fields::parse_no_op, - super::fields::parse_no_op, - super::fields::parse_list_help, - super::fields::parse_no_op, - super::fields::parse_no_op, - super::fields::parse_mime_version, - super::fields::parse_no_op, - super::fields::parse_from, - super::fields::parse_no_op, - super::fields::parse_in_reply_to, - super::fields::parse_no_op, - super::fields::parse_no_op, - super::fields::parse_no_op, - super::fields::parse_no_op, - super::fields::parse_resent_from, +static HDR_MAP: &[HeaderName] = &[ + HeaderName::Date, + HeaderName::Unsupported, + HeaderName::Sender, + HeaderName::Unsupported, + HeaderName::Received, + HeaderName::Unsupported, + HeaderName::References, + HeaderName::Unsupported, + HeaderName::Cc, + HeaderName::Comments, + HeaderName::ResentCc, + HeaderName::ContentId, + HeaderName::Unsupported, + HeaderName::ResentMessageId, + HeaderName::ReplyTo, + HeaderName::ResentTo, + HeaderName::ResentBcc, + HeaderName::ContentLanguage, + HeaderName::Subject, + HeaderName::ResentSender, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::ResentDate, + HeaderName::To, + HeaderName::Bcc, + HeaderName::Unsupported, + HeaderName::ContentTransferEncoding, + HeaderName::ReturnPath, + HeaderName::ListId, + HeaderName::Keywords, + HeaderName::ContentDescription, + HeaderName::ListOwner, + HeaderName::Unsupported, + HeaderName::ContentType, + HeaderName::Unsupported, + HeaderName::ListHelp, + HeaderName::MessageId, + HeaderName::ContentLocation, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::ListSubscribe, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::ListPost, + HeaderName::Unsupported, + HeaderName::ResentFrom, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::ContentDisposition, + HeaderName::Unsupported, + HeaderName::InReplyTo, + HeaderName::ListArchive, + HeaderName::Unsupported, + HeaderName::From, + HeaderName::Unsupported, + HeaderName::ListUnsubscribe, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::Unsupported, + HeaderName::MimeVersion, ]; -static HDR_NAMES: &[&[u8]; 58] = &[ +static HDR_NAMES: &[&[u8]] = &[ b"date", b"", b"sender", - b"subject", + b"", b"received", b"", b"references", - b"resent-date", + b"", b"cc", b"comments", b"resent-cc", b"content-id", - b"return-path", + b"", b"resent-message-id", + b"reply-to", + b"resent-to", + b"resent-bcc", + b"content-language", + b"subject", b"resent-sender", b"", - b"resent-bcc", b"", - b"list-id", + b"resent-date", + b"to", b"bcc", - b"list-post", + b"", + b"content-transfer-encoding", + b"return-path", + b"list-id", + b"keywords", + b"content-description", b"list-owner", b"", b"content-type", - b"keywords", - b"content-description", - b"message-id", b"", - b"to", + b"list-help", + b"message-id", + b"content-location", + b"", b"", b"list-subscribe", - b"content-transfer-encoding", b"", b"", - b"reply-to", - b"resent-to", b"", b"", - b"list-archive", + b"list-post", + b"", + b"resent-from", + b"", b"", b"content-disposition", b"", + b"in-reply-to", + b"list-archive", + b"", + b"from", + b"", b"list-unsubscribe", b"", b"", - b"list-help", + b"", + b"", + b"", + b"", + b"", + b"", b"", b"", b"mime-version", - b"", - b"from", - b"", - b"in-reply-to", - b"", - b"", - b"", - b"", - b"resent-from", ]; diff --git a/src/parsers/message.rs b/src/parsers/message.rs index 1c4b1ec..87ddb98 100644 --- a/src/parsers/message.rs +++ b/src/parsers/message.rs @@ -19,11 +19,11 @@ use crate::{ quoted_printable::decode_quoted_printable, DecodeFnc, DecodeResult, }, - BinaryPart, ContentType, InlinePart, Message, MessageHeader, MessagePart, MimeHeader, TextPart, + BinaryPart, ContentType, HeaderName, HeaderValue, Headers, InlinePart, Message, MessagePart, + TextPart, }; use super::{ - fields::MessageField, header::parse_headers, mime::{get_bytes_to_boundary, seek_next_part, skip_crlf, skip_multipart_end}, }; @@ -151,24 +151,23 @@ impl<'x> MessageStream<'x> { impl<'x> Message<'x> { fn new() -> Message<'x> { Message { - header: Box::new(MessageHeader::new()), + headers: Headers::new(), ..Default::default() } } /// Returns `false` if at least one header field was successfully parsed. pub fn is_empty(&self) -> bool { - self.header.is_empty() + self.headers.is_empty() } /// Parses a byte slice containing the RFC5322 raw message and returns a /// `Message` struct. /// /// This function never panics, a best-effort is made to parse the message and - /// if no headers are found and empty `Message` struct is returned. - /// To make sure parsing was successfull use `is_empty()`. + /// if no headers are found None is returned. /// - pub fn parse(bytes: &'x [u8]) -> Message<'x> { + pub fn parse(bytes: &'x [u8]) -> Option> { let mut stream = MessageStream::new(bytes); let mut message = Message::new(); @@ -177,12 +176,12 @@ impl<'x> Message<'x> { let mut state = MessageParserState::new(); let mut state_stack = Vec::new(); - let mut mime_part_header = MimeHeader::new(); + let mut mime_part_header = Headers::new(); 'outer: loop { // Obtain reference to either the message or the MIME part's header - let header: &mut dyn MessageField = if let MimeType::Message = state.mime_type { - message.header.as_mut() + let header = if let MimeType::Message = state.mime_type { + &mut message.headers } else { &mut mime_part_header }; @@ -194,13 +193,16 @@ impl<'x> Message<'x> { state.parts += 1; + let content_type = header + .get(&HeaderName::ContentType) + .and_then(|c| c.as_content_type_ref()); + let (is_multipart, mut is_inline, mut is_text, mut mime_type) = - get_mime_type(header.get_content_type(), &state.mime_type); + get_mime_type(content_type, &state.mime_type); if is_multipart { - if let Some(mime_boundary) = header - .get_content_type() - .map_or_else(|| None, |f| f.get_attribute("boundary")) + if let Some(mime_boundary) = + content_type.map_or_else(|| None, |f| f.get_attribute("boundary")) { let mime_boundary = ("\n--".to_string() + mime_boundary).into_bytes(); @@ -249,10 +251,14 @@ impl<'x> Message<'x> { skip_crlf(&mut stream); let (is_binary, decode_fnc): (bool, DecodeFnc) = match header - .get_content_transfer_encoding() + .get(&HeaderName::ContentTransferEncoding) { - Some(encoding) if encoding.eq_ignore_ascii_case("base64") => (false, decode_base64), - Some(encoding) if encoding.eq_ignore_ascii_case("quoted-printable") => { + Some(HeaderValue::Text(encoding)) if encoding.eq_ignore_ascii_case("base64") => { + (false, decode_base64) + } + Some(HeaderValue::Text(encoding)) + if encoding.eq_ignore_ascii_case("quoted-printable") => + { (false, decode_quoted_printable) } _ => (true, get_bytes_to_boundary), @@ -316,14 +322,12 @@ impl<'x> Message<'x> { let is_inline = is_inline && header - .get_content_disposition() - .map_or_else(|| true, |d| !d.is_attachment()) + .get(&HeaderName::ContentDisposition) + .map_or_else(|| true, |d| !d.get_content_type().is_attachment()) && (state.parts == 1 || (state.mime_type != MimeType::MultipartRelated && (mime_type == MimeType::Inline - || header - .get_content_type() - .map_or_else(|| true, |c| !c.has_attribute("name"))))); + || content_type.map_or_else(|| true, |c| !c.has_attribute("name"))))); let (add_to_html, add_to_text) = if let MimeType::MultipartAlernative = state.mime_type { @@ -351,8 +355,8 @@ impl<'x> Message<'x> { if is_text { let text_part = TextPart { - contents: result_to_string(bytes, stream.data, header.get_content_type()), - header: if !mime_part_header.is_empty() { + contents: result_to_string(bytes, stream.data, content_type), + headers: if !mime_part_header.is_empty() { Some(std::mem::take(&mut mime_part_header)) } else { None @@ -363,12 +367,12 @@ impl<'x> Message<'x> { if add_to_html && !is_html { message.html_body.push(InlinePart::Text(TextPart { - header: None, + headers: None, contents: text_to_html(&text_part.contents).into(), })); } else if add_to_text && is_html { message.text_body.push(InlinePart::Text(TextPart { - header: None, + headers: None, contents: html_to_text(&text_part.contents).into(), })); } @@ -382,7 +386,7 @@ impl<'x> Message<'x> { } } else { let binary_part = BinaryPart { - header: if !mime_part_header.is_empty() { + headers: if !mime_part_header.is_empty() { Some(std::mem::take(&mut mime_part_header)) } else { None @@ -441,7 +445,7 @@ impl<'x> Message<'x> { for part in message.html_body[state.html_parts..].iter() { message.text_body.push(match part { InlinePart::Text(part) => InlinePart::Text(TextPart { - header: None, + headers: None, contents: html_to_text(&part.contents).into(), }), InlinePart::InlineBinary(index) => { @@ -458,7 +462,7 @@ impl<'x> Message<'x> { for part in message.text_body[state.text_parts..].iter() { message.html_body.push(match part { InlinePart::Text(part) => InlinePart::Text(TextPart { - header: None, + headers: None, contents: text_to_html(&part.contents).into(), }), InlinePart::InlineBinary(index) => { @@ -493,11 +497,17 @@ impl<'x> Message<'x> { } while let Some(mut prev_message) = message_stack.pop() { - prev_message.attachments.push(MessagePart::Message(message)); + if !message.is_empty() { + prev_message.attachments.push(MessagePart::Message(message)); + } message = prev_message; } - message + if !message.is_empty() { + Some(message) + } else { + None + } } } #[cfg(test)] @@ -539,9 +549,7 @@ mod tests { tests_run += 1; let input = input.split_at_mut(pos); - let message = Message::parse(input.0); - - assert!(!message.is_empty()); + let message = Message::parse(input.0).unwrap(); assert_eq!( message, @@ -561,26 +569,27 @@ mod tests { } } - /*#[test] + /* + #[test] fn generate_test_samples() { const SEPARATOR: &[u8] = "\n---- EXPECTED STRUCTURE ----\n".as_bytes(); - for test_suite in ["malformed" /*"legacy","malformed"*/] { + for test_suite in ["malformed", "legacy", "rfc", "thirdparty"] { let mut test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); test_dir.push("tests"); test_dir.push(test_suite); for file_name in fs::read_dir(test_dir).unwrap() { - /*if !file_name + if file_name .as_ref() .unwrap() .path() .to_str() .unwrap() - .contains("001") + .contains("COPYING") { continue; - }*/ + } let mut input = fs::read(file_name.as_ref().unwrap().path()).unwrap(); let mut pos = 0; diff --git a/tests/integration_test.rs b/tests/integration_test.rs index b6f1e8e..b393123 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -50,18 +50,18 @@ fn test_api() { ) .as_bytes(); - let message = Message::parse(input); + let message = Message::parse(input).unwrap(); assert_eq!( message.get_from(), - &Address::Address(Addr { + &HeaderValue::Address(Addr { name: Some("Art Vandelay (Vandelay Industries)".into()), address: Some("art@vandelay.com".into()) }) ); assert_eq!( message.get_to(), - &Address::GroupList(vec![ + &HeaderValue::GroupList(vec![ Group { name: Some("Colleagues".into()), addresses: vec![Addr { @@ -131,8 +131,6 @@ fn test_api() { assert_eq!(nested_attachment.len(), 42); assert_eq!( nested_attachment - .get_header() - .unwrap() .get_content_type() .unwrap() .get_attribute("name") diff --git a/tests/legacy/000.txt b/tests/legacy/000.txt index f16a60b..6b7d113 100644 --- a/tests/legacy/000.txt +++ b/tests/legacy/000.txt @@ -44,17 +44,33 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 35, - "second": 5, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 35, + "second": 5, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "redball.png" + } + } + }, + "subject": { + "Text": "Test message from Microsoft Outlook 00" }, "from": { "Address": { @@ -62,45 +78,26 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGKEKECHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Test message from Microsoft Outlook 00", + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "redball.png" + } + } + }, "to": { "Address": { "name": "Joe Blow", "address": "jblow@example.com" } }, - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "redball.png" - } + "mime_version": { + "Text": "1.0" }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "redball.png" - } - }, - "others": { - "X-MSMail-Priority": [ - "Normal" - ], - "Importance": [ - "Normal" - ], - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ], - "X-Priority": [ - "3 (Normal)" - ] + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGKEKECHAA.doug@example.com" } }, "attachments": [ diff --git a/tests/legacy/001.txt b/tests/legacy/001.txt index 759ba16..fa2840f 100644 --- a/tests/legacy/001.txt +++ b/tests/legacy/001.txt @@ -1,61 +1,47 @@ -From: "Doug Sauder" -To: "Joe Blow" , - =?utf-7?B?SitBUHctcmdlbiBTY2htK0FQdy1yZ2Vu?= -Subject: =?utf-7?Q?Die_Hasen_und_die_Fr+APY-sche_=28Microsoft_Outlook_00=29?= -Date: Wed, 17 May 2000 19:18:39 -0400 -Message-ID: -MIME-Version: 1.0 -Content-Type: text/plain; - charset="utf-7" -Content-Transfer-Encoding: quoted-printable -X-Priority: 3 (Normal) -X-MSMail-Priority: Normal -X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) -Importance: Normal -X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 - -Die Hasen und die Fr+APY-sche - -Die Hasen klagten einst +APw-ber ihre mi+AN8-liche Lage+ADs- +ACI-wir = -leben+ACI-, sprach ein Redner, +ACI-in steter Furcht vor Menschen und = -Tieren, eine Beute der Hunde, der Adler, ja fast aller Raubtiere+ACE- = -Unsere stete Angst ist +AOQ-rger als der Tod selbst. Auf, la+AN8-t uns = -ein f+APw-r allemal sterben.+ACI-=20 - -In einem nahen Teich wollten sie sich nun ers+AOQ-ufen+ADs- sie eilten = -ihm zu+ADs- allein das au+AN8-erordentliche Get+APY-se und ihre = -wunderbare Gestalt erschreckte eine Menge Fr+APY-sche, die am Ufer = -sa+AN8-en, so sehr, da+AN8- sie aufs schnellste untertauchten.=20 - -+ACI-Halt+ACI-, rief nun eben dieser Sprecher, +ACI-wir wollen das = -Ers+AOQ-ufen noch ein wenig aufschieben, denn auch uns f+APw-rchten, wie = -ihr seht, einige Tiere, welche also wohl noch ungl+APw-cklicher sein = -m+APw-ssen als wir.+ACI-=20 - +From: "Doug Sauder" +To: "Joe Blow" , + =?utf-7?B?SitBUHctcmdlbiBTY2htK0FQdy1yZ2Vu?= +Subject: =?utf-7?Q?Die_Hasen_und_die_Fr+APY-sche_=28Microsoft_Outlook_00=29?= +Date: Wed, 17 May 2000 19:18:39 -0400 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-7" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 + +Die Hasen und die Fr+APY-sche + +Die Hasen klagten einst +APw-ber ihre mi+AN8-liche Lage+ADs- +ACI-wir = +leben+ACI-, sprach ein Redner, +ACI-in steter Furcht vor Menschen und = +Tieren, eine Beute der Hunde, der Adler, ja fast aller Raubtiere+ACE- = +Unsere stete Angst ist +AOQ-rger als der Tod selbst. Auf, la+AN8-t uns = +ein f+APw-r allemal sterben.+ACI-=20 + +In einem nahen Teich wollten sie sich nun ers+AOQ-ufen+ADs- sie eilten = +ihm zu+ADs- allein das au+AN8-erordentliche Get+APY-se und ihre = +wunderbare Gestalt erschreckte eine Menge Fr+APY-sche, die am Ufer = +sa+AN8-en, so sehr, da+AN8- sie aufs schnellste untertauchten.=20 + ++ACI-Halt+ACI-, rief nun eben dieser Sprecher, +ACI-wir wollen das = +Ers+AOQ-ufen noch ein wenig aufschieben, denn auch uns f+APw-rchten, wie = +ihr seht, einige Tiere, welche also wohl noch ungl+APw-cklicher sein = +m+APw-ssen als wir.+ACI-=20 + ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 18, - "second": 39, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "mime_version": { + "Text": "1.0" }, - "from": { - "Address": { - "name": "Doug Sauder", - "address": "doug@example.com" - } + "subject": { + "Text": "Die Hasen und die Frösche (Microsoft Outlook 00)" }, - "message_id": "NDBBIAKOPKHFGPLCODIGMEKCCHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche (Microsoft Outlook 00)", "to": { "AddressList": [ { @@ -68,30 +54,39 @@ m+APw-ssen als wir.+ACI-=20 } ] }, - "content_transfer_encoding": "quoted-printable", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "utf-7" + "content_transfer_encoding": { + "Text": "quoted-printable" + }, + "from": { + "Address": { + "name": "Doug Sauder", + "address": "doug@example.com" } }, - "others": { - "X-Priority": [ - "3 (Normal)" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ], - "X-MSMail-Priority": [ - "Normal" - ], - "Importance": [ - "Normal" - ], - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ] + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 18, + "second": 39, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "utf-7" + } + } + }, + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGMEKCCHAA.doug@example.com" } }, "html_body": [ diff --git a/tests/legacy/002.txt b/tests/legacy/002.txt index 2a5a82b..6545441 100644 --- a/tests/legacy/002.txt +++ b/tests/legacy/002.txt @@ -37,17 +37,25 @@ wir."
---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "mime_version": { + "Text": "1.0" + }, + "message_id": { + "Text": "4.2.0.58.20000519003052.00a89c40@pop.example.com" + }, "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 0, - "minute": 31, - "second": 0, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 0, + "minute": 31, + "second": 0, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } }, "from": { "Address": { @@ -55,33 +63,26 @@ wir."
"address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519003052.00a89c40@pop.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "iso-8859-1" + } + } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" + }, + "subject": { + "Text": "Die Hasen und die Frösche" + }, "to": { "Address": { "name": "Heinz Müller", "address": "mueller@example.com" } - }, - "content_transfer_encoding": "quoted-printable", - "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "iso-8859-1" - } - }, - "others": { - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ], - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ], - "X-Priority": [ - "2 (High)" - ] } }, "html_body": [ diff --git a/tests/legacy/003.txt b/tests/legacy/003.txt index 9d98604..8ac5112 100644 --- a/tests/legacy/003.txt +++ b/tests/legacy/003.txt @@ -64,17 +64,12 @@ wir."
---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 0, - "minute": 29, - "second": 55, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "message_id": { + "Text": "4.2.0.58.20000519002557.00a88870@pop.example.com" + }, + "subject": { + "Text": "Die Hasen und die Frösche" }, "from": { "Address": { @@ -82,44 +77,52 @@ wir."
"address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519002557.00a88870@pop.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "alternative", + "attributes": { + "boundary": "=====================_714967308==_.ALT" + } + } + }, + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 0, + "minute": 29, + "second": 55, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "mime_version": { + "Text": "1.0" + }, "to": { "Address": { "name": "Heinz Müller", "address": "mueller@example.com" } - }, - "content_type": { - "c_type": "multipart", - "c_subtype": "alternative", - "attributes": { - "boundary": "=====================_714967308==_.ALT" - } - }, - "others": { - "X-Priority": [ - "2 (High)" - ], - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ], - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ] } }, "html_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "\nDie Hasen und die\nFrösche
\n
\n
Die Hasen klagten einst über\nihre mißliche Lage; "wir leben", sprach ein Redner, "in\nsteter Furcht vor Menschen und Tieren, eine Beute der Hunde, der Adler,\nja fast aller Raubtiere! Unsere stete Angst ist ärger als der Tod selbst.\nAuf, laßt uns ein für allemal sterben."
\n
\nIn einem nahen Teich wollten sie sich nun ersäufen; sie eilten ihm zu;\nallein das außerordentliche Getöse und ihre wunderbare Gestalt\nerschreckte eine Menge Frösche, die am Ufer saßen, so sehr, daß sie aufs\nschnellste untertauchten.
\n
\n"Halt", rief nun eben dieser Sprecher, "wir wollen das\nErsäufen noch ein wenig aufschieben, denn auch uns fürchten, wie ihr\nseht, einige Tiere, welche also wohl noch unglücklicher sein müssen als\nwir."
\n
\n
\n" @@ -127,14 +130,18 @@ wir."
], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "Die Hasen und die Frösche\n\nDie Hasen klagten einst über ihre mißliche Lage; \"wir leben\", sprach ein Redner, \"in steter Furcht vor Menschen und Tieren, eine Beute der Hunde, der Adler, ja fast aller Raubtiere! Unsere stete Angst ist ärger als der Tod selbst. Auf, laßt uns ein für allemal sterben.\" \n\nIn einem nahen Teich wollten sie sich nun ersäufen; sie eilten ihm zu; allein das außerordentliche Getöse und ihre wunderbare Gestalt erschreckte eine Menge Frösche, die am Ufer saßen, so sehr, daß sie aufs schnellste untertauchten. \n\n\"Halt\", rief nun eben dieser Sprecher, \"wir wollen das Ersäufen noch ein wenig aufschieben, denn auch uns fürchten, wie ihr seht, einige Tiere, welche also wohl noch unglücklicher sein müssen als wir.\" \n\n" diff --git a/tests/legacy/004.txt b/tests/legacy/004.txt index d00d52e..4b89efe 100644 --- a/tests/legacy/004.txt +++ b/tests/legacy/004.txt @@ -19,17 +19,27 @@ Slow but steady wins the race. ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 1, - "minute": 13, - "second": 19, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "to": { + "Address": { + "name": "Joe Blow", + "address": "blow@example.com" + } + }, + "mime_version": { + "Text": "1.0" + }, + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } + } + }, + "subject": { + "Text": "The Hare and the Tortoise" }, "from": { "Address": { @@ -37,32 +47,21 @@ Slow but steady wins the race. "address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519011207.00a8cd70@pop.example.com", - "mime_version": "1.0", - "subject": "The Hare and the Tortoise", - "to": { - "Address": { - "name": "Joe Blow", - "address": "blow@example.com" + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 1, + "minute": 13, + "second": 19, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 } }, - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" - } - }, - "others": { - "X-Priority": [ - "5 (Lowest)" - ], - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ], - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ] + "message_id": { + "Text": "4.2.0.58.20000519011207.00a8cd70@pop.example.com" } }, "html_body": [ diff --git a/tests/legacy/005.txt b/tests/legacy/005.txt index ebe76fa..db32d35 100644 --- a/tests/legacy/005.txt +++ b/tests/legacy/005.txt @@ -33,17 +33,37 @@ m+APw-ssen als wir.+ACI-=20 ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "to": { + "Address": { + "name": "Heinz Müller", + "address": "mueller@example.com" + } + }, + "subject": { + "Text": "Die Hasen und die Frösche (Microsoft Outlook 00)" + }, + "mime_version": { + "Text": "1.0" + }, + "content_transfer_encoding": { + "Text": "quoted-printable" + }, "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 20, - "second": 24, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 20, + "second": 24, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGCEKDCHAA.doug@example.com" }, "from": { "Address": { @@ -51,39 +71,14 @@ m+APw-ssen als wir.+ACI-=20 "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGCEKDCHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche (Microsoft Outlook 00)", - "to": { - "Address": { - "name": "Heinz Müller", - "address": "mueller@example.com" - } - }, - "content_transfer_encoding": "quoted-printable", "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "utf-7" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "utf-7" + } } - }, - "others": { - "Importance": [ - "Normal" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ], - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "X-Priority": [ - "3 (Normal)" - ], - "X-MSMail-Priority": [ - "Normal" - ] } }, "html_body": [ diff --git a/tests/legacy/006.txt b/tests/legacy/006.txt index f59c25c..aefeb28 100644 --- a/tests/legacy/006.txt +++ b/tests/legacy/006.txt @@ -84,17 +84,21 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 36, - "second": 13, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "subject": { + "Text": "Test message from Microsoft Outlook 00" + }, + "mime_version": { + "Text": "1.0" + }, + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "----=_NextPart_000_0004_01BFC037.28F2FA90" + } + } }, "from": { "Address": { @@ -102,56 +106,51 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGOEKECHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Test message from Microsoft Outlook 00", + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGOEKECHAA.doug@example.com" + }, "to": { "Address": { "name": "Joe Blow", "address": "jblow@example.com" } }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "----=_NextPart_000_0004_01BFC037.28F2FA90" + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 36, + "second": 13, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 } - }, - "others": { - "Importance": [ - "Normal" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ], - "X-MSMail-Priority": [ - "Normal" - ], - "X-Priority": [ - "3 (Normal)" - ], - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ] } }, "attachments": [ { "Binary": { - "header": { + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "blueball.png" + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "blueball.png" + } } }, - "content_transfer_encoding": "base64", "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } } }, @@ -1486,19 +1485,25 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== }, { "Binary": { - "header": { - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "redball.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "redball.png" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "redball.png" + "content_transfer_encoding": { + "Text": "base64" + }, + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "redball.png" + } } } }, diff --git a/tests/legacy/007.txt b/tests/legacy/007.txt index dd28bb1..22458af 100644 --- a/tests/legacy/007.txt +++ b/tests/legacy/007.txt @@ -32,17 +32,9 @@ Tiere, welche also wohl noch ungl=FCcklicher sein m=FCssen als wir."=20 ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 15, - "second": 35, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "content_transfer_encoding": { + "Text": "quoted-printable" }, "from": { "Address": { @@ -50,39 +42,42 @@ Tiere, welche also wohl noch ungl=FCcklicher sein m=FCssen als wir."=20 "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGIEKCCHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche (Microsoft Outlook 00)", + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } + } + }, + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGIEKCCHAA.doug@example.com" + }, + "mime_version": { + "Text": "1.0" + }, "to": { "Address": { "name": "Jürgen Schmürgen", "address": "schmuergen@example.com" } }, - "content_transfer_encoding": "quoted-printable", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" - } + "subject": { + "Text": "Die Hasen und die Frösche (Microsoft Outlook 00)" }, - "others": { - "X-Priority": [ - "3 (Normal)" - ], - "Importance": [ - "Normal" - ], - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "X-MSMail-Priority": [ - "Normal" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ] + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 15, + "second": 35, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } } }, "html_body": [ diff --git a/tests/legacy/008.txt b/tests/legacy/008.txt index bbb66a9..68143fa 100644 --- a/tests/legacy/008.txt +++ b/tests/legacy/008.txt @@ -136,17 +136,28 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 32, - "second": 47, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 32, + "second": 47, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "subject": { + "Text": "Test message from Microsoft Outlook 00" + }, + "to": { + "Address": { + "name": "Heinz Müller", + "address": "mueller@example.com" + } }, "from": { "Address": { @@ -154,38 +165,20 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGGEKECHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Test message from Microsoft Outlook 00", - "to": { - "Address": { - "name": "Heinz Müller", - "address": "mueller@example.com" - } + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGGEKECHAA.doug@example.com" }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "----=_NextPart_000_0002_01BFC036.AE309650" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "----=_NextPart_000_0002_01BFC036.AE309650" + } } }, - "others": { - "X-Priority": [ - "3 (Normal)" - ], - "X-MSMail-Priority": [ - "Normal" - ], - "Importance": [ - "Normal" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ], - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ] + "mime_version": { + "Text": "1.0" } }, "html_body": [ @@ -195,14 +188,18 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "\nThe Hare and the Tortoise \n \nA HARE one day ridiculed the short feet and slow pace of the Tortoise, who replied, laughing: \"Though you be swift as the wind, I will beat you in a race.\" The Hare, believing her assertion to be simply impossible, assented to the proposal; and they agreed that the Fox should choose the course and fix the goal. On the day appointed for the race the two started together. The Tortoise never for a moment stopped, but went on with a slow but steady pace straight to the end of the course. The Hare, lying down by the wayside, fell fast asleep. At last waking up, and moving as fast as he could, he saw the Tortoise had reached the goal, and was comfortably dozing after her fatigue. \n \nSlow but steady wins the race. \n" @@ -211,19 +208,25 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "attachments": [ { "Binary": { - "header": { - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "blueball.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "content_transfer_encoding": { + "Text": "base64" + }, + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "blueball.png" + } } } }, @@ -1558,19 +1561,25 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== }, { "Binary": { - "header": { + "headers": { "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "greenball.png" + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "greenball.png" + } } }, - "content_transfer_encoding": "base64", + "content_transfer_encoding": { + "Text": "base64" + }, "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "greenball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "greenball.png" + } } } }, @@ -2878,19 +2887,25 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== }, { "Binary": { - "header": { - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "redball.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "redball.png" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "redball.png" + "content_transfer_encoding": { + "Text": "base64" + }, + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "redball.png" + } } } }, diff --git a/tests/legacy/009.txt b/tests/legacy/009.txt index 2304287..c2c602d 100644 --- a/tests/legacy/009.txt +++ b/tests/legacy/009.txt @@ -37,17 +37,25 @@ welche also wohl noch ungl=FCcklicher sein m=FCssen als wir." ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "mime_version": { + "Text": "1.0" + }, + "message_id": { + "Text": "4.2.0.58.20000519010441.00a8d140@pop.example.com" + }, "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 1, - "minute": 6, - "second": 18, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 1, + "minute": 6, + "second": 18, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } }, "from": { "Address": { @@ -55,37 +63,27 @@ welche also wohl noch ungl=FCcklicher sein m=FCssen als wir." "address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519010441.00a8d140@pop.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1", + "format": "flowed" + } + } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" + }, "to": { "Address": { "name": "Jürgen Schmürgen", "address": "jschmuergen@example.com" } }, - "content_transfer_encoding": "quoted-printable", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1", - "format": "flowed" - } - }, - "others": { - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ], - "X-Priority": [ - "1 (Highest)" - ], - "Disposition-Notification-To": [ - "" - ], - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ] + "subject": { + "Text": "Die Hasen und die Frösche" } }, "html_body": [ diff --git a/tests/legacy/010.txt b/tests/legacy/010.txt index 31c5986..ed4bb73 100644 --- a/tests/legacy/010.txt +++ b/tests/legacy/010.txt @@ -22,17 +22,21 @@ In einem nahen Teich wollten sie sich nun ers ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 1, - "minute": 10, - "second": 27, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "content_transfer_encoding": { + "Text": "8bit" + }, + "mime_version": { + "Text": "1.0" + }, + "message_id": { + "Text": "4.2.0.58.20000519010842.00a8c7f0@pop.example.com" + }, + "to": { + "Address": { + "name": "Heinz M�ller", + "address": "mueller@example.com" + } }, "from": { "Address": { @@ -40,33 +44,30 @@ In einem nahen Teich wollten sie sich nun ers "address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519010842.00a8c7f0@pop.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Fr�sche", - "to": { - "Address": { - "name": "Heinz M�ller", - "address": "mueller@example.com" - } - }, - "content_transfer_encoding": "8bit", "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } }, - "others": { - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ], - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ], - "X-Priority": [ - "1 (Highest)" - ] + "subject": { + "Text": "Die Hasen und die Fr�sche" + }, + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 1, + "minute": 10, + "second": 27, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } } }, "html_body": [ diff --git a/tests/legacy/011.txt b/tests/legacy/011.txt index ca398b0..01ce03e 100644 --- a/tests/legacy/011.txt +++ b/tests/legacy/011.txt @@ -30,17 +30,19 @@ In einem nahen Teich wollten sie sich nun ers=E4ufen; sie eilten ihm zu;= ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 0, - "minute": 17, - "second": 39, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 0, + "minute": 17, + "second": 39, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } }, "from": { "Address": { @@ -48,30 +50,32 @@ In einem nahen Teich wollten sie sich nun ers=E4ufen; sie eilten ihm zu;= "address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519001217.00a85b60@pop.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } + } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" + }, + "message_id": { + "Text": "4.2.0.58.20000519001217.00a85b60@pop.example.com" + }, "to": { "Address": { "name": "Jürgen Schmürgen", "address": "jschmuergen@example.com" } }, - "content_transfer_encoding": "quoted-printable", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" - } + "mime_version": { + "Text": "1.0" }, - "others": { - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ], - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ] + "subject": { + "Text": "Die Hasen und die Frösche" } }, "html_body": [ diff --git a/tests/legacy/012.txt b/tests/legacy/012.txt index ed33d5b..d3d3992 100644 --- a/tests/legacy/012.txt +++ b/tests/legacy/012.txt @@ -31,17 +31,37 @@ Tiere, welche also wohl noch ungl=FCcklicher sein m=FCssen als wir."=20 ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "Windows-1252" + } + } + }, + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGCEKECHAA.doug@example.com" + }, + "mime_version": { + "Text": "1.0" + }, + "subject": { + "Text": "Die Hasen und die Frösche (Microsoft Outlook 00)" + }, "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 30, - "second": 20, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 30, + "second": 20, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } }, "from": { "Address": { @@ -49,39 +69,14 @@ Tiere, welche also wohl noch ungl=FCcklicher sein m=FCssen als wir."=20 "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGCEKECHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche (Microsoft Outlook 00)", "to": { "Address": { "name": "Heinz Müller", "address": "mueller@example.com" } }, - "content_transfer_encoding": "quoted-printable", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "Windows-1252" - } - }, - "others": { - "X-MSMail-Priority": [ - "Normal" - ], - "Importance": [ - "Normal" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ], - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "X-Priority": [ - "3 (Normal)" - ] + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "html_body": [ diff --git a/tests/legacy/013.txt b/tests/legacy/013.txt index 8a1e69f..de3f8a6 100644 --- a/tests/legacy/013.txt +++ b/tests/legacy/013.txt @@ -32,17 +32,30 @@ welche also wohl noch ungl ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 13, - "second": 51, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "content_transfer_encoding": { + "Text": "8bit" + }, + "mime_version": { + "Text": "1.0" + }, + "to": { + "Address": { + "name": "Jürgen Schmürgen", + "address": "schmuergen@example.com" + } + }, + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } + } + }, + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGEEKCCHAA.doug@example.com" }, "from": { "Address": { @@ -50,39 +63,21 @@ welche also wohl noch ungl "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGEEKCCHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche (Microsoft Outlook 00)", - "to": { - "Address": { - "name": "Jürgen Schmürgen", - "address": "schmuergen@example.com" - } + "subject": { + "Text": "Die Hasen und die Frösche (Microsoft Outlook 00)" }, - "content_transfer_encoding": "8bit", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 13, + "second": 51, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 } - }, - "others": { - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "Importance": [ - "Normal" - ], - "X-Priority": [ - "3 (Normal)" - ], - "X-MSMail-Priority": [ - "Normal" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ] } }, "html_body": [ diff --git a/tests/legacy/014.txt b/tests/legacy/014.txt index 377e4ef..db0a6a3 100644 --- a/tests/legacy/014.txt +++ b/tests/legacy/014.txt @@ -73,17 +73,18 @@ race. =20 ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 38, - "second": 28, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGCEKFCHAA.doug@example.com" + }, + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "alternative", + "attributes": { + "boundary": "----=_NextPart_000_0005_01BFC037.799BEF60" + } + } }, "from": { "Address": { @@ -91,50 +92,46 @@ race. =20 "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGCEKFCHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Test message from Microsoft Outlook 00", "to": { "Address": { "name": "Joe Blow", "address": "jblow@example.com" } }, - "content_type": { - "c_type": "multipart", - "c_subtype": "alternative", - "attributes": { - "boundary": "----=_NextPart_000_0005_01BFC037.799BEF60" + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 38, + "second": 28, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 } }, - "others": { - "X-MSMail-Priority": [ - "Normal" - ], - "X-Priority": [ - "3 (Normal)" - ], - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "Importance": [ - "Normal" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ] + "mime_version": { + "Text": "1.0" + }, + "subject": { + "Text": "Test message from Microsoft Outlook 00" } }, "html_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "\n\n\n\n\n

The Hare and the Tortoise
 
A HARE \none day ridiculed the short feet and slow pace of the Tortoise, who replied, \nlaughing:  \"Though you be swift as the wind, I will beat you in a \nrace.\"  The Hare, believing her assertion to be simply impossible, assented \nto the proposal; and they agreed that the Fox should choose the course and fix \nthe goal.  On the day appointed for the race the two started \ntogether.  The Tortoise never for a moment stopped, but went on with a slow \nbut steady pace straight to the end of the course.  The Hare, lying down by \nthe wayside, fell fast asleep.  At last waking up, and moving as fast as he \ncould, he saw the Tortoise had reached the goal, and was comfortably dozing \nafter her fatigue. 
 
Slow but steady wins the race.  \n
\n" @@ -142,13 +139,17 @@ race. =20 ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { + "content_transfer_encoding": { + "Text": "quoted-printable" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } } }, diff --git a/tests/legacy/015.txt b/tests/legacy/015.txt index fec0a7e..1ae594b 100644 --- a/tests/legacy/015.txt +++ b/tests/legacy/015.txt @@ -199,17 +199,34 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "=====================_715392540==_" + } + } + }, + "message_id": { + "Text": "4.2.0.58.20000519003556.00a918e0@pop.example.com" + }, "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 0, - "minute": 36, - "second": 58, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 0, + "minute": 36, + "second": 58, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "subject": { + "Text": "Die Hasen und die Frösche" }, "from": { "Address": { @@ -217,44 +234,30 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= "address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519003556.00a918e0@pop.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", + "mime_version": { + "Text": "1.0" + }, "to": { "Address": { "name": "Heinz Müller", "address": "mueller@example.com" } - }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "=====================_715392540==_" - } - }, - "others": { - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ], - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ], - "X-Priority": [ - "2 (High)" - ] } }, "html_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "\nDie Hasen und die\nFrösche
\n
\n
Die Hasen klagten einst über\nihre mißliche Lage; "wir leben", sprach ein Redner, "in\nsteter Furcht vor Menschen und Tieren, eine Beute der Hunde, der Adler,\nja fast aller Raubtiere! Unsere stete Angst ist ärger als der Tod selbst.\nAuf, laßt uns ein für allemal sterben."
\n
\nIn einem nahen Teich wollten sie sich nun ersäufen; sie eilten ihm zu;\nallein das außerordentliche Getöse und ihre wunderbare Gestalt\nerschreckte eine Menge Frösche, die am Ufer saßen, so sehr, daß sie aufs\nschnellste untertauchten.
\n
\n"Halt", rief nun eben dieser Sprecher, "wir wollen das\nErsäufen noch ein wenig aufschieben, denn auch uns fürchten, wie ihr\nseht, einige Tiere, welche also wohl noch unglücklicher sein müssen als\nwir."
\n
\n
\"2aa3ed95.png\"\"2aa3edd1.png\"\n" @@ -262,14 +265,18 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "Die Hasen und die Frösche\n\nDie Hasen klagten einst über ihre mißliche Lage; \"wir leben\", sprach ein Redner, \"in steter Furcht vor Menschen und Tieren, eine Beute der Hunde, der Adler, ja fast aller Raubtiere! Unsere stete Angst ist ärger als der Tod selbst. Auf, laßt uns ein für allemal sterben.\" \n\nIn einem nahen Teich wollten sie sich nun ersäufen; sie eilten ihm zu; allein das außerordentliche Getöse und ihre wunderbare Gestalt erschreckte eine Menge Frösche, die am Ufer saßen, so sehr, daß sie aufs schnellste untertauchten. \n\n\"Halt\", rief nun eben dieser Sprecher, \"wir wollen das Ersäufen noch ein wenig aufschieben, denn auch uns fürchten, wie ihr seht, einige Tiere, welche also wohl noch unglücklicher sein müssen als wir.\" \n\n2aa3ed95.png2aa3edd1.png" @@ -278,20 +285,28 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= "attachments": [ { "Binary": { - "header": { + "headers": { "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "2aa3ed95.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "2aa3ed95.png" + } } }, - "content_id": "4.2.0.58.20000519003556.00a918e0@pop.example.com.2", - "content_transfer_encoding": "base64", + "content_transfer_encoding": { + "Text": "base64" + }, + "content_id": { + "Text": "4.2.0.58.20000519003556.00a918e0@pop.example.com.2" + }, "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "2aa3ed95.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "2aa3ed95.png" + } } } }, @@ -1626,21 +1641,29 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "Binary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "2aa3edd1.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "2aa3edd1.png" + } } }, - "content_id": "4.2.0.58.20000519003556.00a918e0@pop.example.com.3", - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "2aa3edd1.png" + "content_transfer_encoding": { + "Text": "base64" + }, + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "2aa3edd1.png" + } } + }, + "content_id": { + "Text": "4.2.0.58.20000519003556.00a918e0@pop.example.com.3" } }, "contents": [ @@ -3102,20 +3125,26 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "Binary": { - "header": { - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "blueball.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "blueball.png" + } } + }, + "content_transfer_encoding": { + "Text": "base64" } }, "contents": [ @@ -4449,20 +4478,26 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "Binary": { - "header": { + "headers": { "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "greenball.png" + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "greenball.png" + } } }, - "content_transfer_encoding": "base64", "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "greenball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "greenball.png" + } } + }, + "content_transfer_encoding": { + "Text": "base64" } }, "contents": [ diff --git a/tests/legacy/016.txt b/tests/legacy/016.txt index 5d7f9fa..0f2bb53 100644 --- a/tests/legacy/016.txt +++ b/tests/legacy/016.txt @@ -96,17 +96,34 @@ JB@ac)(GTFLiL)!d09'8!!!: ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 0, - "minute": 53, - "second": 25, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 0, + "minute": 53, + "second": 25, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "to": { + "Address": { + "name": "Jürgen Schmürgen", + "address": "jschmuergen@example.com" + } + }, + "subject": { + "Text": "Die Hasen und die Frösche" + }, + "mime_version": { + "Text": "1.0" + }, + "message_id": { + "Text": "4.2.0.58.20000519005150.00a85230@pop.example.com" }, "from": { "Address": { @@ -114,29 +131,14 @@ JB@ac)(GTFLiL)!d09'8!!!: "address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519005150.00a85230@pop.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", - "to": { - "Address": { - "name": "Jürgen Schmürgen", - "address": "jschmuergen@example.com" - } - }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "=====================_716373961==_" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "=====================_716373961==_" + } } - }, - "others": { - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ], - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ] } }, "html_body": [ @@ -146,13 +148,17 @@ JB@ac)(GTFLiL)!d09'8!!!: ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { + "content_transfer_encoding": { + "Text": "quoted-printable" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } } }, @@ -162,18 +168,22 @@ JB@ac)(GTFLiL)!d09'8!!!: "attachments": [ { "Binary": { - "header": { - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "blueball.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "application", + "c_subtype": "mac-binhex40", + "attributes": { + "name": "blueball.png" + } } }, - "content_type": { - "c_type": "application", - "c_subtype": "mac-binhex40", - "attributes": { - "name": "blueball.png" + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "blueball.png" + } } } }, @@ -2113,18 +2123,22 @@ JB@ac)(GTFLiL)!d09'8!!!: }, { "Binary": { - "header": { + "headers": { "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "HasenundFr�sche.txt" + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "HasenundFr�sche.txt" + } } }, "content_type": { - "c_type": "application", - "c_subtype": "mac-binhex40", - "attributes": { - "name": "HasenundFr�sche.txt" + "ContentType": { + "c_type": "application", + "c_subtype": "mac-binhex40", + "attributes": { + "name": "HasenundFr�sche.txt" + } } } }, diff --git a/tests/legacy/017.txt b/tests/legacy/017.txt index 34185f1..e2f6265 100644 --- a/tests/legacy/017.txt +++ b/tests/legacy/017.txt @@ -103,17 +103,19 @@ end ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 0, - "minute": 50, - "second": 8, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 0, + "minute": 50, + "second": 8, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } }, "from": { "Address": { @@ -121,29 +123,29 @@ end "address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519004755.00a86100@pop.example.com", - "mime_version": "1.0", - "subject": "The Hare and the Tortoise", + "mime_version": { + "Text": "1.0" + }, + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "=====================_716177458==_" + } + } + }, + "subject": { + "Text": "The Hare and the Tortoise" + }, "to": { "Address": { "name": "J�rgen Schm�rgen", "address": "jschmuergen@example.com" } }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "=====================_716177458==_" - } - }, - "others": { - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ], - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ] + "message_id": { + "Text": "4.2.0.58.20000519004755.00a86100@pop.example.com" } }, "html_body": [ @@ -153,12 +155,14 @@ end ], "text_body": [ { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } } }, @@ -168,19 +172,25 @@ end "attachments": [ { "Binary": { - "header": { + "headers": { "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "greenball.png" + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "greenball.png" + } } }, - "content_transfer_encoding": "x-uuencode", + "content_transfer_encoding": { + "Text": "x-uuencode" + }, "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "greenball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "greenball.png" + } } } }, @@ -2045,19 +2055,25 @@ end }, { "Binary": { - "header": { - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "blueball.png" + "headers": { + "content_transfer_encoding": { + "Text": "x-uuencode" + }, + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } }, - "content_transfer_encoding": "x-uuencode", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "blueball.png" + } } } }, diff --git a/tests/legacy/018.txt b/tests/legacy/018.txt index 7261eda..489c5aa 100644 --- a/tests/legacy/018.txt +++ b/tests/legacy/018.txt @@ -139,17 +139,28 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 0, - "minute": 33, - "second": 1, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 0, + "minute": 33, + "second": 1, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "message_id": { + "Text": "4.2.0.58.20000519003143.00a8d550@pop.example.com" + }, + "subject": { + "Text": "Die Hasen und die Frösche" + }, + "mime_version": { + "Text": "1.0" }, "from": { "Address": { @@ -157,44 +168,36 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519003143.00a8d550@pop.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "related", + "attributes": { + "type": "multipart/alternative", + "boundary": "=====================_715157131==_.REL" + } + } + }, "to": { "Address": { "name": "Heinz Müller", "address": "mueller@example.com" } - }, - "content_type": { - "c_type": "multipart", - "c_subtype": "related", - "attributes": { - "boundary": "=====================_715157131==_.REL", - "type": "multipart/alternative" - } - }, - "others": { - "X-Priority": [ - "2 (High)" - ], - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ], - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ] } }, "html_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { + "content_transfer_encoding": { + "Text": "quoted-printable" + }, "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "iso-8859-1" + } } } }, @@ -203,13 +206,17 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { + "content_transfer_encoding": { + "Text": "quoted-printable" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } } }, @@ -219,20 +226,28 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "attachments": [ { "Binary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "blueball.png" + "headers": { + "content_id": { + "Text": "4.2.0.58.20000519003143.00a8d550@pop.example.com.0" + }, + "content_transfer_encoding": { + "Text": "base64" + }, + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } }, - "content_id": "4.2.0.58.20000519003143.00a8d550@pop.example.com.0", - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "blueball.png" + } } } }, @@ -1567,20 +1582,28 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== }, { "Binary": { - "header": { + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, + "content_id": { + "Text": "4.2.0.58.20000519003143.00a8d550@pop.example.com.1" + }, "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "redball.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "redball.png" + } } }, - "content_id": "4.2.0.58.20000519003143.00a8d550@pop.example.com.1", - "content_transfer_encoding": "base64", "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "redball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "redball.png" + } } } }, diff --git a/tests/legacy/019.txt b/tests/legacy/019.txt index 78b1c11..ac6fd75 100644 --- a/tests/legacy/019.txt +++ b/tests/legacy/019.txt @@ -145,68 +145,65 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 42, - "second": 10, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 - }, + "headers": { "from": { "Address": { "name": "Doug Sauder", "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGGEKFCHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Test message from Microsoft Outlook 00", + "subject": { + "Text": "Test message from Microsoft Outlook 00" + }, + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 42, + "second": 10, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "----=_NextPart_000_0008_01BFC037.FDD8EE90" + } + } + }, + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGGEKFCHAA.doug@example.com" + }, + "mime_version": { + "Text": "1.0" + }, "to": { "Address": { "name": "Joe Blow", "address": "jblow@example.com" } - }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "----=_NextPart_000_0008_01BFC037.FDD8EE90" - } - }, - "others": { - "X-MSMail-Priority": [ - "Normal" - ], - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "Importance": [ - "Normal" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ], - "X-Priority": [ - "3 (Normal)" - ] } }, "html_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "\n\n\n\n\n

The Hare and the Tortoise
 
A HARE \none day ridiculed the short feet and slow pace of the Tortoise, who replied, \nlaughing:  \"Though you be swift as the wind, I will beat you in a \nrace.\"  The Hare, believing her assertion to be simply impossible, assented \nto the proposal; and they agreed that the Fox should choose the course and fix \nthe goal.  On the day appointed for the race the two started \ntogether.  The Tortoise never for a moment stopped, but went on with a slow \nbut steady pace straight to the end of the course.  The Hare, lying down by \nthe wayside, fell fast asleep.  At last waking up, and moving as fast as he \ncould, he saw the Tortoise had reached the goal, and was comfortably dozing \nafter her fatigue. 
 
Slow but steady wins the race.  \n
\n" @@ -214,14 +211,18 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "\nThe Hare and the Tortoise \n \nA HARE one day ridiculed the short feet and slow pace of the Tortoise, who replied, laughing: \"Though you be swift as the wind, I will beat you in a race.\" The Hare, believing her assertion to be simply impossible, assented to the proposal; and they agreed that the Fox should choose the course and fix the goal. On the day appointed for the race the two started together. The Tortoise never for a moment stopped, but went on with a slow but steady pace straight to the end of the course. The Hare, lying down by the wayside, fell fast asleep. At last waking up, and moving as fast as he could, he saw the Tortoise had reached the goal, and was comfortably dozing after her fatigue. \n \nSlow but steady wins the race. \n\n" @@ -230,19 +231,25 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "attachments": [ { "Binary": { - "header": { + "headers": { "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "greenball.png" + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "greenball.png" + } } }, - "content_transfer_encoding": "base64", + "content_transfer_encoding": { + "Text": "base64" + }, "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "greenball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "greenball.png" + } } } }, @@ -1550,19 +1557,25 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== }, { "Binary": { - "header": { - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "redball.png" + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "redball.png" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "redball.png" + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "redball.png" + } } } }, diff --git a/tests/legacy/020.txt b/tests/legacy/020.txt index bbfc023..4a18028 100644 --- a/tests/legacy/020.txt +++ b/tests/legacy/020.txt @@ -32,17 +32,40 @@ welche also wohl noch ungl ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGIEKBCHAA.doug@example.com" + }, + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } + } + }, + "subject": { + "Text": "Die Hasen und die Fr�sche (Microsoft Outlook 00)" + }, "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 8, - "second": 29, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 8, + "second": 29, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "mime_version": { + "Text": "1.0" + }, + "content_transfer_encoding": { + "Text": "8bit" }, "from": { "Address": { @@ -50,39 +73,11 @@ welche also wohl noch ungl "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGIEKBCHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Fr�sche (Microsoft Outlook 00)", "to": { "Address": { "name": "J�rgen Schm�rgen", "address": "schmuergen@example.com" } - }, - "content_transfer_encoding": "8bit", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" - } - }, - "others": { - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ], - "Importance": [ - "Normal" - ], - "X-MSMail-Priority": [ - "Normal" - ], - "X-Priority": [ - "3 (Normal)" - ] } }, "html_body": [ diff --git a/tests/legacy/021.txt b/tests/legacy/021.txt index b4d3ec0..772750b 100644 --- a/tests/legacy/021.txt +++ b/tests/legacy/021.txt @@ -189,17 +189,30 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 47, - "second": 24, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGOEKFCHAA.doug@example.com" + }, + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "----=_NextPart_000_0010_01BFC038.B91BC650" + } + } + }, + "mime_version": { + "Text": "1.0" + }, + "subject": { + "Text": "Test message from Microsoft Outlook 00" + }, + "to": { + "Address": { + "name": "Joe Blow", + "address": "jblow@example.com" + } }, "from": { "Address": { @@ -207,50 +220,34 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGOEKFCHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Test message from Microsoft Outlook 00", - "to": { - "Address": { - "name": "Joe Blow", - "address": "jblow@example.com" + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 47, + "second": 24, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 } - }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "----=_NextPart_000_0010_01BFC038.B91BC650" - } - }, - "others": { - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "X-MSMail-Priority": [ - "Normal" - ], - "X-Priority": [ - "3 (Normal)" - ], - "Importance": [ - "Normal" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ] } }, "html_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "\n\n\n\n\n
\"blue
\n

The Hare and the Tortoise
 
A HARE \none day ridiculed the short feet and slow pace of the Tortoise, who replied, \nlaughing:  \"Though you be swift as the wind, I will beat you in a \nrace.\"  The Hare, believing her assertion to be simply impossible, assented \nto the proposal; and they agreed that the Fox should choose the course and fix \nthe goal.  On the day appointed for the race the two started \ntogether.  The Tortoise never for a moment stopped, but went on with a slow \nbut steady pace straight to the end of the course.  The Hare, lying down by \nthe wayside, fell fast asleep.  At last waking up, and moving as fast as he \ncould, he saw the Tortoise had reached the goal, and was comfortably dozing \nafter her fatigue. 
 
Slow but steady wins the race.  \n
\n

 
\n" @@ -258,13 +255,17 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { + "content_transfer_encoding": { + "Text": "quoted-printable" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } } }, @@ -274,15 +275,21 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "attachments": [ { "Binary": { - "header": { - "content_id": "938014623@17052000-0f9b", - "content_transfer_encoding": "base64", + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } + }, + "content_id": { + "Text": "938014623@17052000-0f9b" } }, "contents": [ @@ -1616,19 +1623,25 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== }, { "Binary": { - "header": { - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "greenball.png" + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "greenball.png" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "greenball.png" + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "greenball.png" + } } } }, @@ -2936,19 +2949,25 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== }, { "Binary": { - "header": { + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "redball.png" + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "redball.png" + } } }, - "content_transfer_encoding": "base64", "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "redball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "redball.png" + } } } }, diff --git a/tests/legacy/022.txt b/tests/legacy/022.txt index 252edf8..74443f5 100644 --- a/tests/legacy/022.txt +++ b/tests/legacy/022.txt @@ -31,17 +31,37 @@ IiANCg== ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "subject": { + "Text": "Die Hasen und die Fr�sche (Microsoft Outlook 00)" + }, + "content_transfer_encoding": { + "Text": "base64" + }, + "to": { + "Address": { + "name": "J�rgen Schm�rgen", + "address": "schmuergen@example.com" + } + }, + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGAEKCCHAA.doug@example.com" + }, + "mime_version": { + "Text": "1.0" + }, "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 11, - "second": 50, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 11, + "second": 50, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } }, "from": { "Address": { @@ -49,39 +69,14 @@ IiANCg== "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGAEKCCHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Fr�sche (Microsoft Outlook 00)", - "to": { - "Address": { - "name": "J�rgen Schm�rgen", - "address": "schmuergen@example.com" - } - }, - "content_transfer_encoding": "base64", "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } - }, - "others": { - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "X-MSMail-Priority": [ - "Normal" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ], - "Importance": [ - "Normal" - ], - "X-Priority": [ - "3 (Normal)" - ] } }, "html_body": [ diff --git a/tests/legacy/023.txt b/tests/legacy/023.txt index 94f2336..cfa7fca 100644 --- a/tests/legacy/023.txt +++ b/tests/legacy/023.txt @@ -109,47 +109,49 @@ In einem nahen Teich wollten sie sich nun ers=E4ufen; sie eilten ihm zu;= ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 0, - "minute": 56, - "second": 13, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 - }, + "headers": { "from": { "Address": { "name": "Doug Sauder", "address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519005505.00a853a0@pop.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", + "subject": { + "Text": "Die Hasen und die Frösche" + }, "to": { "Address": { "name": "Jürgen Schmürgen", "address": "jschmuergen@example.com" } }, + "mime_version": { + "Text": "1.0" + }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "=====================_716541962==_" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "=====================_716541962==_" + } } }, - "others": { - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ], - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ] + "message_id": { + "Text": "4.2.0.58.20000519005505.00a853a0@pop.example.com" + }, + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 0, + "minute": 56, + "second": 13, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } } }, "html_body": [ @@ -159,14 +161,18 @@ In einem nahen Teich wollten sie sich nun ers=E4ufen; sie eilten ihm zu;= ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "Die Hasen und die Frösche\n\nDie Hasen klagten einst über ihre mißliche Lage; \"wir leben\", sprach ein Redner, \"in steter Furcht vor Menschen und Tieren, eine Beute der Hunde, der Adler, ja fast aller Raubtiere! Unsere stete Angst ist ärger als der Tod selbst. Auf, laßt uns ein für allemal sterben.\" \n\nIn einem nahen Teich wollten sie sich nun ersäufen; sie eilten ihm zu; allein das außerordentliche Getöse und ihre wunderbare Gestalt erschreckte eine Menge Frösche, die am Ufer saßen, so sehr, daß sie aufs schnellste untertauchten. \n\n\"Halt\", rief nun eben dieser Sprecher, \"wir wollen das Ersäufen noch ein wenig aufschieben, denn auch uns fürchten, wie ihr seht, einige Tiere, welche also wohl noch unglücklicher sein müssen als wir.\" \n\n" @@ -175,19 +181,25 @@ In einem nahen Teich wollten sie sich nun ers=E4ufen; sie eilten ihm zu;= "attachments": [ { "Binary": { - "header": { + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "blueball.png" + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "blueball.png" + } } }, - "content_transfer_encoding": "base64", "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } } }, @@ -1522,18 +1534,22 @@ In einem nahen Teich wollten sie sich nun ers=E4ufen; sie eilten ihm zu;= }, { "Text": { - "header": { - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "farmerandstork.txt" + "headers": { + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } }, - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "farmerandstork.txt" + } } } }, @@ -1542,20 +1558,26 @@ In einem nahen Teich wollten sie sich nun ers=E4ufen; sie eilten ihm zu;= }, { "Text": { - "header": { + "headers": { "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "HasenundFr�sche.txt" + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "HasenundFr�sche.txt" + } } }, - "content_transfer_encoding": "quoted-printable", "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "Die Hasen und die Frösche\n\nDie Hasen klagten einst über ihre mißliche Lage; \"wir leben\", sprach ein Redner, \"in steter Furcht vor Menschen und Tieren, eine Beute der Hunde, der Adler, ja fast aller Raubtiere! Unsere stete Angst ist ärger als der Tod selbst. Auf, laßt uns ein für allemal sterben.\" \n\nIn einem nahen Teich wollten sie sich nun ersäufen; sie eilten ihm zu; allein das außerordentliche Getöse und ihre wunderbare Gestalt erschreckte eine Menge Frösche, die am Ufer saßen, so sehr, daß sie aufs schnellste untertauchten. \n\n\"Halt\", rief nun eben dieser Sprecher, \"wir wollen das Ersäufen noch ein wenig aufschieben, denn auch uns fürchten, wie ihr seht, einige Tiere, welche also wohl noch unglücklicher sein müssen als wir.\" \n\n" diff --git a/tests/legacy/024.txt b/tests/legacy/024.txt index 074f129..57d1da3 100644 --- a/tests/legacy/024.txt +++ b/tests/legacy/024.txt @@ -110,17 +110,41 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "related", + "attributes": { + "type": "text/html", + "boundary": "=====================_715429112==_.REL" + } + } + }, + "mime_version": { + "Text": "1.0" + }, + "message_id": { + "Text": "4.2.0.58.20000519003735.00a8d7e0@pop.example.com" + }, + "to": { + "Address": { + "name": "Heinz Müller", + "address": "mueller@example.com" + } + }, "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 0, - "minute": 37, - "second": 39, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 0, + "minute": 37, + "second": 39, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } }, "from": { "Address": { @@ -128,45 +152,24 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519003735.00a8d7e0@pop.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", - "to": { - "Address": { - "name": "Heinz Müller", - "address": "mueller@example.com" - } - }, - "content_type": { - "c_type": "multipart", - "c_subtype": "related", - "attributes": { - "type": "text/html", - "boundary": "=====================_715429112==_.REL" - } - }, - "others": { - "X-Priority": [ - "2 (High)" - ], - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ], - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ] + "subject": { + "Text": "Die Hasen und die Frösche" } }, "html_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "\n\"2aa48eb6.png\"
\n
\nDie Hasen und die\nFrösche
\n
\n
Die Hasen klagten einst über\nihre mißliche Lage; "wir leben", sprach ein Redner, "in\nsteter Furcht vor Menschen und Tieren, eine Beute der Hunde, der Adler,\nja fast aller Raubtiere! Unsere stete Angst ist ärger als der Tod selbst.\nAuf, laßt uns ein für allemal sterben."
\n
\nIn einem nahen Teich wollten sie sich nun ersäufen; sie eilten ihm zu;\nallein das außerordentliche Getöse und ihre wunderbare Gestalt\nerschreckte eine Menge Frösche, die am Ufer saßen, so sehr, daß sie aufs\nschnellste untertauchten.
\n
\n"Halt", rief nun eben dieser Sprecher, "wir wollen das\nErsäufen noch ein wenig aufschieben, denn auch uns fürchten, wie ihr\nseht, einige Tiere, welche also wohl noch unglücklicher sein müssen als\nwir."
\n
\n\"2aa48ec0.png\"
\n" @@ -180,20 +183,28 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "attachments": [ { "Binary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "2aa48eb6.png" + "headers": { + "content_id": { + "Text": "4.2.0.58.20000519003735.00a8d7e0@pop.example.com.2" + }, + "content_transfer_encoding": { + "Text": "base64" + }, + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "2aa48eb6.png" + } } }, - "content_id": "4.2.0.58.20000519003735.00a8d7e0@pop.example.com.2", - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "2aa48eb6.png" + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "2aa48eb6.png" + } } } }, @@ -1528,21 +1539,29 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== }, { "Binary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "2aa48ec0.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "2aa48ec0.png" + } } }, - "content_id": "4.2.0.58.20000519003735.00a8d7e0@pop.example.com.3", - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "2aa48ec0.png" + "content_id": { + "Text": "4.2.0.58.20000519003735.00a8d7e0@pop.example.com.3" + }, + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "2aa48ec0.png" + } } + }, + "content_transfer_encoding": { + "Text": "base64" } }, "contents": [ diff --git a/tests/legacy/025.txt b/tests/legacy/025.txt index a9c9488..5bbcf48 100644 --- a/tests/legacy/025.txt +++ b/tests/legacy/025.txt @@ -172,17 +172,31 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 0, - "minute": 38, - "second": 13, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 0, + "minute": 38, + "second": 13, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "to": { + "Address": { + "name": "Heinz Müller", + "address": "mueller@example.com" + } + }, + "subject": { + "Text": "Die Hasen und die Frösche" + }, + "message_id": { + "Text": "4.2.0.58.20000519003809.00a85140@pop.example.com" }, "from": { "Address": { @@ -190,43 +204,32 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= "address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519003809.00a85140@pop.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", - "to": { - "Address": { - "name": "Heinz Müller", - "address": "mueller@example.com" - } + "mime_version": { + "Text": "1.0" }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "=====================_715462801==_" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "=====================_715462801==_" + } } - }, - "others": { - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ], - "X-Priority": [ - "2 (High)" - ], - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ] } }, "html_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { + "content_transfer_encoding": { + "Text": "quoted-printable" + }, "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "iso-8859-1" + } } } }, @@ -241,21 +244,29 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= "attachments": [ { "Binary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "2aa51367.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "2aa51367.png" + } } }, - "content_id": "4.2.0.58.20000519003809.00a85140@pop.example.com.2", - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "2aa51367.png" + "content_id": { + "Text": "4.2.0.58.20000519003809.00a85140@pop.example.com.2" + }, + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "2aa51367.png" + } } + }, + "content_transfer_encoding": { + "Text": "base64" } }, "contents": [ @@ -1589,20 +1600,28 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "Binary": { - "header": { + "headers": { + "content_id": { + "Text": "4.2.0.58.20000519003809.00a85140@pop.example.com.3" + }, + "content_transfer_encoding": { + "Text": "base64" + }, "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "2aa51371.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "2aa51371.png" + } } }, - "content_id": "4.2.0.58.20000519003809.00a85140@pop.example.com.3", - "content_transfer_encoding": "base64", "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "2aa51371.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "2aa51371.png" + } } } }, @@ -3065,19 +3084,25 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "Binary": { - "header": { - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "blueball.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "content_transfer_encoding": { + "Text": "base64" + }, + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "blueball.png" + } } } }, @@ -4412,19 +4437,25 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "Binary": { - "header": { + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "greenball.png" + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "greenball.png" + } } }, - "content_transfer_encoding": "base64", "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "greenball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "greenball.png" + } } } }, diff --git a/tests/legacy/026.txt b/tests/legacy/026.txt index ec2ff4e..2aa1c6f 100644 --- a/tests/legacy/026.txt +++ b/tests/legacy/026.txt @@ -85,17 +85,22 @@ Birds of a feather flock together. ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 0, - "minute": 59, - "second": 31, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 0, + "minute": 59, + "second": 31, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "mime_version": { + "Text": "1.0" }, "from": { "Address": { @@ -103,9 +108,9 @@ Birds of a feather flock together. "address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519005818.00a86aa0@pop.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", + "message_id": { + "Text": "4.2.0.58.20000519005818.00a86aa0@pop.example.com" + }, "to": { "Address": { "name": "Heinz Müller", @@ -113,19 +118,16 @@ Birds of a feather flock together. } }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "=====================_716740438==_" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "=====================_716740438==_" + } } }, - "others": { - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ], - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ] + "subject": { + "Text": "Die Hasen und die Frösche" } }, "html_body": [ @@ -135,14 +137,18 @@ Birds of a feather flock together. ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "Die Hasen und die Frösche\n\nDie Hasen klagten einst über ihre mißliche Lage; \"wir leben\", sprach ein Redner, \"in steter Furcht vor Menschen und Tieren, eine Beute der Hunde, der Adler, ja fast aller Raubtiere! Unsere stete Angst ist ärger als der Tod selbst. Auf, laßt uns ein für allemal sterben.\" \n\nIn einem nahen Teich wollten sie sich nun ersäufen; sie eilten ihm zu; allein das außerordentliche Getöse und ihre wunderbare Gestalt erschreckte eine Menge Frösche, die am Ufer saßen, so sehr, daß sie aufs schnellste untertauchten. \n\n\"Halt\", rief nun eben dieser Sprecher, \"wir wollen das Ersäufen noch ein wenig aufschieben, denn auch uns fürchten, wie ihr seht, einige Tiere, welche also wohl noch unglücklicher sein müssen als wir.\" \n\n" @@ -151,21 +157,27 @@ Birds of a feather flock together. "attachments": [ { "Text": { - "header": { + "headers": { + "content_transfer_encoding": { + "Text": "x-uuencode" + }, "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "HasenundFr�sche.txt" + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "HasenundFr�sche.txt" + } } }, - "content_transfer_encoding": "x-uuencode", "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "x-mac-creator": "74747874", - "name": "HasenundFr�sche.txt", - "x-mac-type": "54455854" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "x-mac-type": "54455854", + "x-mac-creator": "74747874", + "name": "HasenundFr�sche.txt" + } } } }, @@ -174,18 +186,22 @@ Birds of a feather flock together. }, { "Text": { - "header": { - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "farmerandstork.txt" + "headers": { + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } }, - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "farmerandstork.txt" + } } } }, diff --git a/tests/legacy/027.txt b/tests/legacy/027.txt index 6205f67..eb093aa 100644 --- a/tests/legacy/027.txt +++ b/tests/legacy/027.txt @@ -32,17 +32,9 @@ Tiere, welche also wohl noch ungl=FCcklicher sein m=FCssen als wir."=20 ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 10, - "second": 31, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "mime_version": { + "Text": "1.0" }, "from": { "Address": { @@ -50,39 +42,42 @@ Tiere, welche also wohl noch ungl=FCcklicher sein m=FCssen als wir."=20 "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGMEKBCHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Fr�sche (Microsoft Outlook 00)", + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 10, + "second": 31, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } + } + }, "to": { "Address": { "name": "J�rgen Schm�rgen", "address": "schmuergen@example.com" } }, - "content_transfer_encoding": "quoted-printable", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" - } + "subject": { + "Text": "Die Hasen und die Fr�sche (Microsoft Outlook 00)" }, - "others": { - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ], - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "Importance": [ - "Normal" - ], - "X-MSMail-Priority": [ - "Normal" - ], - "X-Priority": [ - "3 (Normal)" - ] + "content_transfer_encoding": { + "Text": "quoted-printable" + }, + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGMEKBCHAA.doug@example.com" } }, "html_body": [ diff --git a/tests/legacy/028.txt b/tests/legacy/028.txt index 6256842..86f651d 100644 --- a/tests/legacy/028.txt +++ b/tests/legacy/028.txt @@ -157,17 +157,12 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 44, - "second": 45, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "subject": { + "Text": "Test message from Microsoft Outlook 00" + }, + "mime_version": { + "Text": "1.0" }, "from": { "Address": { @@ -175,50 +170,52 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGKEKFCHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Test message from Microsoft Outlook 00", + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 44, + "second": 45, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "related", + "attributes": { + "boundary": "----=_NextPart_000_000C_01BFC038.5A5C8E60" + } + } + }, "to": { "Address": { "name": "Joe Blow", "address": "jblow@example.com" } }, - "content_type": { - "c_type": "multipart", - "c_subtype": "related", - "attributes": { - "boundary": "----=_NextPart_000_000C_01BFC038.5A5C8E60" - } - }, - "others": { - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "X-MSMail-Priority": [ - "Normal" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ], - "X-Priority": [ - "3 (Normal)" - ], - "Importance": [ - "Normal" - ] + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGKEKFCHAA.doug@example.com" } }, "html_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "\n\n\n\n\n

The Hare and the Tortoise
 
A HARE \none day ridiculed the short feet and slow pace of the Tortoise, who replied, \nlaughing:  \"Though you be swift as the wind, I will beat you in a \nrace.\"  The Hare, believing her assertion to be simply impossible, assented \nto the proposal; and they agreed that the Fox should choose the course and fix \nthe goal.  On the day appointed for the race the two started \ntogether.  The Tortoise never for a moment stopped, but went on with a slow \nbut steady pace straight to the end of the course.  The Hare, lying down by \nthe wayside, fell fast asleep.  At last waking up, and moving as fast as he \ncould, he saw the Tortoise had reached the goal, and was comfortably dozing \nafter her fatigue.  
\n
 
\n
\"blue
 
Slow but steady wins \nthe race. 
\n
 
\n
\"red
\n" @@ -226,13 +223,17 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { + "content_transfer_encoding": { + "Text": "quoted-printable" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } } }, @@ -242,15 +243,21 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "attachments": [ { "Binary": { - "header": { - "content_id": "823504223@17052000-0f8d", - "content_transfer_encoding": "base64", + "headers": { "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } + }, + "content_transfer_encoding": { + "Text": "base64" + }, + "content_id": { + "Text": "823504223@17052000-0f8d" } }, "contents": [ @@ -1584,14 +1591,20 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== }, { "Binary": { - "header": { - "content_id": "823504223@17052000-0f94", - "content_transfer_encoding": "base64", + "headers": { + "content_id": { + "Text": "823504223@17052000-0f94" + }, + "content_transfer_encoding": { + "Text": "base64" + }, "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "redball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "redball.png" + } } } }, diff --git a/tests/legacy/029.txt b/tests/legacy/029.txt index df6490b..193a2dc 100644 --- a/tests/legacy/029.txt +++ b/tests/legacy/029.txt @@ -28,17 +28,31 @@ Slow but steady wins the race. ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 23, - "minute": 26, - "second": 16, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 23, + "minute": 26, + "second": 16, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "content_transfer_encoding": { + "Text": "7bit" + }, + "to": { + "Address": { + "name": "Joe Blow", + "address": "blow@example.com" + } + }, + "message_id": { + "Text": "392362D8.B650789F@example.com" }, "from": { "Address": { @@ -46,33 +60,20 @@ Slow but steady wins the race. "address": "dwsauder@example.com" } }, - "message_id": "392362D8.B650789F@example.com", - "mime_version": "1.0", - "subject": "Test message from Netscape Communicator 4.7", - "to": { - "Address": { - "name": "Joe Blow", - "address": "blow@example.com" - } + "mime_version": { + "Text": "1.0" }, - "content_transfer_encoding": "7bit", "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } }, - "others": { - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ], - "X-Accept-Language": [ - "en" - ], - "X-Priority": [ - "1 (Highest)" - ] + "subject": { + "Text": "Test message from Netscape Communicator 4.7" } }, "html_body": [ diff --git a/tests/legacy/030.txt b/tests/legacy/030.txt index 1a14312..14d1046 100644 --- a/tests/legacy/030.txt +++ b/tests/legacy/030.txt @@ -112,17 +112,15 @@ Slow but steady wins the race. ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 23, - "minute": 28, - "second": 27, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "------------0BBC657DDC74A0B8454627FD" + } + } }, "from": { "Address": { @@ -130,29 +128,33 @@ Slow but steady wins the race. "address": "dwsauder@example.com" } }, - "message_id": "3923635B.85C58444@example.com", - "mime_version": "1.0", - "subject": "Test message from Netscape Communicator 4.7", + "message_id": { + "Text": "3923635B.85C58444@example.com" + }, + "mime_version": { + "Text": "1.0" + }, + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 23, + "minute": 28, + "second": 27, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "subject": { + "Text": "Test message from Netscape Communicator 4.7" + }, "to": { "Address": { "name": "Joe Blow", "address": "blow@example.com" } - }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "------------0BBC657DDC74A0B8454627FD" - } - }, - "others": { - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ], - "X-Accept-Language": [ - "en" - ] } }, "html_body": [ @@ -164,13 +166,17 @@ Slow but steady wins the race. ], "text_body": [ { - "header": { - "content_transfer_encoding": "7bit", + "headers": { + "content_transfer_encoding": { + "Text": "7bit" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } } }, @@ -182,19 +188,25 @@ Slow but steady wins the race. "attachments": [ { "InlineBinary": { - "header": { + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "blueball.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "blueball.png" + } } }, - "content_transfer_encoding": "base64", "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } } }, @@ -1529,19 +1541,25 @@ Slow but steady wins the race. }, { "InlineBinary": { - "header": { + "headers": { "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "greenball.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "greenball.png" + } } }, - "content_transfer_encoding": "base64", + "content_transfer_encoding": { + "Text": "base64" + }, "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "greenball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "greenball.png" + } } } }, @@ -2849,20 +2867,26 @@ Slow but steady wins the race. }, { "Text": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "hareandtoroise.txt" + "headers": { + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "name": "hareandtoroise.txt", + "charset": "us-ascii" + } } }, - "content_transfer_encoding": "7bit", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "name": "hareandtoroise.txt", - "charset": "us-ascii" + "content_transfer_encoding": { + "Text": "7bit" + }, + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "hareandtoroise.txt" + } } } }, diff --git a/tests/legacy/031.txt b/tests/legacy/031.txt index 413f2c8..929d4b2 100644 --- a/tests/legacy/031.txt +++ b/tests/legacy/031.txt @@ -97,17 +97,24 @@ Z3VldDZzO7wAAAAASUVORK5CYII= ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 9, - "minute": 55, - "second": 48, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "subject": { + "Text": "Test message from PINE" + }, + "message_id": { + "Text": "Pine.LNX.4.21.0005190951410.8452-102000@penguin.example.com" + }, + "mime_version": { + "Text": "1.0" + }, + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "-1463757054-952513540-958744548=:8452" + } + } }, "from": { "Address": { @@ -115,21 +122,24 @@ Z3VldDZzO7wAAAAASUVORK5CYII= "address": "doug@penguin.example.com" } }, - "message_id": "Pine.LNX.4.21.0005190951410.8452-102000@penguin.example.com", - "mime_version": "1.0", - "subject": "Test message from PINE", + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 9, + "minute": 55, + "second": 48, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, "to": { "Address": { "name": "Joe Blow", "address": "blow@example.com" } - }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "-1463757054-952513540-958744548=:8452" - } } }, "html_body": [ @@ -139,12 +149,14 @@ Z3VldDZzO7wAAAAASUVORK5CYII= ], "text_body": [ { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "US-ASCII" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "US-ASCII" + } } } }, @@ -154,22 +166,32 @@ Z3VldDZzO7wAAAAASUVORK5CYII= "attachments": [ { "Binary": { - "header": { - "content_description": "A PNG graphic file", - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "redball.png" + "headers": { + "content_transfer_encoding": { + "Text": "BASE64" + }, + "content_description": { + "Text": "A PNG graphic file" + }, + "content_type": { + "ContentType": { + "c_type": "application", + "c_subtype": "octet-stream", + "attributes": { + "name": "redball.png" + } } }, - "content_id": "Pine.LNX.4.21.0005190955480.8452@penguin.example.com", - "content_transfer_encoding": "BASE64", - "content_type": { - "c_type": "application", - "c_subtype": "octet-stream", - "attributes": { - "name": "redball.png" + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "redball.png" + } } + }, + "content_id": { + "Text": "Pine.LNX.4.21.0005190955480.8452@penguin.example.com" } }, "contents": [ @@ -1631,21 +1653,31 @@ Z3VldDZzO7wAAAAASUVORK5CYII= }, { "Binary": { - "header": { - "content_description": "A PNG graphic file", - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "blueball.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "application", + "c_subtype": "octet-stream", + "attributes": { + "name": "blueball.png" + } } }, - "content_id": "Pine.LNX.4.21.0005190955481.8452@penguin.example.com", - "content_transfer_encoding": "BASE64", - "content_type": { - "c_type": "application", - "c_subtype": "octet-stream", - "attributes": { - "name": "blueball.png" + "content_description": { + "Text": "A PNG graphic file" + }, + "content_id": { + "Text": "Pine.LNX.4.21.0005190955481.8452@penguin.example.com" + }, + "content_transfer_encoding": { + "Text": "BASE64" + }, + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "blueball.png" + } } } }, diff --git a/tests/legacy/032.txt b/tests/legacy/032.txt index e52354b..f5c6adf 100644 --- a/tests/legacy/032.txt +++ b/tests/legacy/032.txt @@ -134,17 +134,9 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 23, - "minute": 8, - "second": 29, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "message_id": { + "Text": "39235EAD.E48E2160@example.com" }, "from": { "Address": { @@ -152,40 +144,54 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= "address": "dwsauder@example.com" } }, - "message_id": "39235EAD.E48E2160@example.com", - "mime_version": "1.0", - "subject": "Test message from Netscape Communicator 4.7", + "mime_version": { + "Text": "1.0" + }, "to": { "Address": { "name": "Joe Blow", "address": "blow@example.com" } }, + "subject": { + "Text": "Test message from Netscape Communicator 4.7" + }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "------------C78F594988075E36AE03C243" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "------------C78F594988075E36AE03C243" + } } }, - "others": { - "X-Accept-Language": [ - "en" - ], - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ] + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 23, + "minute": 8, + "second": 29, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } } }, "html_body": [ { - "header": { - "content_transfer_encoding": "7bit", + "headers": { + "content_transfer_encoding": { + "Text": "7bit" + }, "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "us-ascii" + } } } }, @@ -196,13 +202,17 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { + "content_transfer_encoding": { + "Text": "quoted-printable" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } } }, @@ -214,19 +224,25 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= "attachments": [ { "InlineBinary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "greenball.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "greenball.png" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "greenball.png" + "content_transfer_encoding": { + "Text": "base64" + }, + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "greenball.png" + } } } }, @@ -1534,19 +1550,25 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "InlineBinary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "blueball.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "content_transfer_encoding": { + "Text": "base64" + }, + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "blueball.png" + } } } }, diff --git a/tests/legacy/033.txt b/tests/legacy/033.txt index 5efd0a8..b96776f 100644 --- a/tests/legacy/033.txt +++ b/tests/legacy/033.txt @@ -34,51 +34,52 @@ welche also wohl noch ungl=FCcklicher sein m=FCssen als wir." ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 23, - "minute": 30, - "second": 41, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 - }, + "headers": { "from": { "Address": { "name": "Doug Sauder", "address": "dwsauder@example.com" } }, - "message_id": "392363E1.2AC47AB3@example.com", - "mime_version": "1.0", - "subject": "Test message from Netscape Communicator 4.7", + "mime_version": { + "Text": "1.0" + }, "to": { "Address": { "name": "Joe Blow", "address": "blow@example.com" } }, - "content_transfer_encoding": "quoted-printable", "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "UTF-8" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "UTF-8" + } } }, - "others": { - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ], - "X-Accept-Language": [ - "en" - ], - "X-Priority": [ - "5 (Lowest)" - ] + "subject": { + "Text": "Test message from Netscape Communicator 4.7" + }, + "content_transfer_encoding": { + "Text": "quoted-printable" + }, + "message_id": { + "Text": "392363E1.2AC47AB3@example.com" + }, + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 23, + "minute": 30, + "second": 41, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } } }, "html_body": [ diff --git a/tests/legacy/034.txt b/tests/legacy/034.txt index 65129a8..0da6a83 100644 --- a/tests/legacy/034.txt +++ b/tests/legacy/034.txt @@ -27,17 +27,37 @@ welche also wohl noch ungl+uKs-licher sein m+vLM-en als wir." ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "UTF-7" + } + } + }, + "mime_version": { + "Text": "1.0" + }, "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 23, - "minute": 33, - "second": 43, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 23, + "minute": 33, + "second": 43, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "to": { + "Address": { + "name": "Heinz M+APw-ller", + "address": "mueller@example.com" + } }, "from": { "Address": { @@ -45,30 +65,14 @@ welche also wohl noch ungl+uKs-licher sein m+vLM-en als wir." "address": "dwsauder@example.com" } }, - "message_id": "39236497.12FA2A89@example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Fr+APY-sche", - "to": { - "Address": { - "name": "Heinz M+APw-ller", - "address": "mueller@example.com" - } + "content_transfer_encoding": { + "Text": "7bit" }, - "content_transfer_encoding": "7bit", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "UTF-7" - } + "subject": { + "Text": "Die Hasen und die Fr+APY-sche" }, - "others": { - "X-Accept-Language": [ - "en" - ], - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ] + "message_id": { + "Text": "39236497.12FA2A89@example.com" } }, "html_body": [ diff --git a/tests/legacy/035.txt b/tests/legacy/035.txt index b060b1c..a560991 100644 --- a/tests/legacy/035.txt +++ b/tests/legacy/035.txt @@ -213,58 +213,64 @@ YII= ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 23, - "minute": 13, - "second": 9, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "mime_version": { + "Text": "1.0" }, - "from": { - "Address": { - "name": "Doug Sauder", - "address": "dwsauder@example.com" - } - }, - "message_id": "39235FC5.276CCE00@example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche (Netscape Messenger 4.7)", "to": { "Address": { "name": "Heinz Müller", "address": "mueller@example.com" } }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "------------A1E83A41894D3755390B838A" + "subject": { + "Text": "Die Hasen und die Frösche (Netscape Messenger 4.7)" + }, + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 23, + "minute": 13, + "second": 9, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 } }, - "others": { - "X-Accept-Language": [ - "en" - ], - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ] + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "------------A1E83A41894D3755390B838A" + } + } + }, + "message_id": { + "Text": "39235FC5.276CCE00@example.com" + }, + "from": { + "Address": { + "name": "Doug Sauder", + "address": "dwsauder@example.com" + } } }, "html_body": [ { - "header": { - "content_transfer_encoding": "7bit", + "headers": { + "content_transfer_encoding": { + "Text": "7bit" + }, "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "us-ascii" + } } } }, @@ -275,14 +281,18 @@ YII= ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "[blue ball]\n\nDie Hasen und die Frösche\n\nDie Hasen klagten einst über ihre mißliche Lage; \"wir leben\", sprach ein\nRedner, \"in steter Furcht vor Menschen und Tieren, eine Beute der Hunde,\nder Adler, ja fast aller Raubtiere! Unsere stete Angst ist ärger als der\nTod selbst. Auf, laßt uns ein für allemal sterben.\"\n\nIn einem nahen Teich wollten sie sich nun ersäufen; sie eilten ihm zu;\nallein das außerordentliche Getöse und ihre wunderbare Gestalt\nerschreckte eine Menge Frösche, die am Ufer saßen, so sehr, daß sie aufs\nschnellste untertauchten.\n\n\"Halt\", rief nun eben dieser Sprecher, \"wir wollen das Ersäufen noch ein\nwenig aufschieben, denn auch uns fürchten, wie ihr seht, einige Tiere,\nwelche also wohl noch unglücklicher sein müssen als wir.\"\n\n[Image]\n\n\n" @@ -293,18 +303,26 @@ YII= "attachments": [ { "Binary": { - "header": { + "headers": { "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "C:TEMPnsmailEG.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "C:TEMPnsmailEG.png" + } } }, - "content_id": "part1.39235FC5.E71D8178@example.com", - "content_transfer_encoding": "base64", "content_type": { - "c_type": "image", - "c_subtype": "png" + "ContentType": { + "c_type": "image", + "c_subtype": "png" + } + }, + "content_id": { + "Text": "part1.39235FC5.E71D8178@example.com" + }, + "content_transfer_encoding": { + "Text": "base64" } }, "contents": [ @@ -1638,18 +1656,26 @@ YII= }, { "Binary": { - "header": { + "headers": { "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "C:TEMPnsmail39.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "C:TEMPnsmail39.png" + } } }, - "content_id": "part2.39235FC5.E71D8178@example.com", - "content_transfer_encoding": "base64", "content_type": { - "c_type": "image", - "c_subtype": "png" + "ContentType": { + "c_type": "image", + "c_subtype": "png" + } + }, + "content_id": { + "Text": "part2.39235FC5.E71D8178@example.com" + }, + "content_transfer_encoding": { + "Text": "base64" } }, "contents": [ @@ -3111,19 +3137,25 @@ YII= }, { "InlineBinary": { - "header": { + "headers": { "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "redball.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "redball.png" + } } }, - "content_transfer_encoding": "base64", + "content_transfer_encoding": { + "Text": "base64" + }, "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "redball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "redball.png" + } } } }, @@ -4586,20 +4618,26 @@ YII= }, { "InlineBinary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "greenball.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "greenball.png" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "greenball.png" + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "greenball.png" + } } + }, + "content_transfer_encoding": { + "Text": "base64" } }, "contents": [ diff --git a/tests/legacy/036.txt b/tests/legacy/036.txt index 5460950..6190930 100644 --- a/tests/legacy/036.txt +++ b/tests/legacy/036.txt @@ -27,40 +27,52 @@ lche also wohl noch ungl=FCcklicher sein m=FCssen als wir."=20 ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 10, - "minute": 18, - "second": 3, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 - }, + "headers": { "from": { "Address": { "name": "Doug Sauder", "address": "doug@penguin.example.com" } }, - "message_id": "Pine.LNX.4.21.0005191014500.8452-100000@penguin.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 10, + "minute": 18, + "second": 3, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "subject": { + "Text": "Die Hasen und die Frösche" + }, + "mime_version": { + "Text": "1.0" + }, + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } + } + }, "to": { "Address": { "name": "Jürgen Schmürgen", "address": "schmuergen@example.com" } }, - "content_transfer_encoding": "QUOTED-PRINTABLE", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" - } + "content_transfer_encoding": { + "Text": "QUOTED-PRINTABLE" + }, + "message_id": { + "Text": "Pine.LNX.4.21.0005191014500.8452-100000@penguin.example.com" } }, "html_body": [ diff --git a/tests/legacy/037.txt b/tests/legacy/037.txt index 944aab4..1c20d4c 100644 --- a/tests/legacy/037.txt +++ b/tests/legacy/037.txt @@ -52,27 +52,13 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 23, - "minute": 42, - "second": 31, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "message_id": { + "Text": "392366A7.21929EA7@example.com" }, - "from": { - "Address": { - "name": "Doug Sauder", - "address": "dwsauder@example.com" - } + "subject": { + "Text": "Test message from Netscape Communicator 4.7" }, - "message_id": "392366A7.21929EA7@example.com", - "mime_version": "1.0", - "subject": "Test message from Netscape Communicator 4.7", "to": { "Address": { "name": "Joe Blow", @@ -80,19 +66,35 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= } }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "------------E7889DDF0F75D34163841C59" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "------------E7889DDF0F75D34163841C59" + } } }, - "others": { - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ], - "X-Accept-Language": [ - "en" - ] + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 23, + "minute": 42, + "second": 31, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "mime_version": { + "Text": "1.0" + }, + "from": { + "Address": { + "name": "Doug Sauder", + "address": "dwsauder@example.com" + } } }, "html_body": [ @@ -103,14 +105,18 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= ], "text_body": [ { - "header": { - "content_transfer_encoding": "7bit", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } + }, + "content_transfer_encoding": { + "Text": "7bit" } }, "contents": " \r" @@ -120,19 +126,25 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= "attachments": [ { "InlineBinary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "blueball.png" + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "blueball.png" + } } } }, diff --git a/tests/legacy/038.txt b/tests/legacy/038.txt index 5c613ab..e8f9b3b 100644 --- a/tests/legacy/038.txt +++ b/tests/legacy/038.txt @@ -18,48 +18,52 @@ Slow but steady wins the race. ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 23, - "minute": 24, - "second": 11, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 - }, + "headers": { "from": { "Address": { "name": "Doug Sauder", "address": "dwsauder@example.com" } }, - "message_id": "3923625B.59F0C3AC@example.com", - "mime_version": "1.0", - "subject": "Test message from Netscape Communicator 4.7", + "mime_version": { + "Text": "1.0" + }, + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 23, + "minute": 24, + "second": 11, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "content_transfer_encoding": { + "Text": "7bit" + }, "to": { "Address": { "name": "Joe Blow", "address": "blow@example.com" } }, - "content_transfer_encoding": "7bit", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" - } + "message_id": { + "Text": "3923625B.59F0C3AC@example.com" }, - "others": { - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ], - "X-Accept-Language": [ - "en" - ] + "subject": { + "Text": "Test message from Netscape Communicator 4.7" + }, + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } + } } }, "html_body": [ diff --git a/tests/legacy/039.txt b/tests/legacy/039.txt index 9f2311a..144deab 100644 --- a/tests/legacy/039.txt +++ b/tests/legacy/039.txt @@ -172,17 +172,34 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "mime_version": { + "Text": "1.0" + }, "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 23, - "minute": 18, - "second": 27, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 23, + "minute": 18, + "second": 27, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "subject": { + "Text": "Test message from Netscape Communicator 4.7" + }, + "message_id": { + "Text": "39236103.FFE674FC@example.com" + }, + "to": { + "Address": { + "name": "Jürgen Schmürgen", + "address": "schmuergen@example.com" + } }, "from": { "Address": { @@ -190,41 +207,30 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= "address": "dwsauder@example.com" } }, - "message_id": "39236103.FFE674FC@example.com", - "mime_version": "1.0", - "subject": "Test message from Netscape Communicator 4.7", - "to": { - "Address": { - "name": "Jürgen Schmürgen", - "address": "schmuergen@example.com" - } - }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "------------B7133A01A6B323BF00DBC9A7" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "------------B7133A01A6B323BF00DBC9A7" + } } - }, - "others": { - "X-Accept-Language": [ - "en" - ], - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ] } }, "html_body": [ { - "header": { - "content_transfer_encoding": "7bit", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "us-ascii" + } } + }, + "content_transfer_encoding": { + "Text": "7bit" } }, "contents": "\r\n\r\n\"blue\r\n

Die Hasen und die Frösche\r\n

Die Hasen klagten einst über ihre mißliche Lage; \"wir leben\",\r\nsprach ein Redner, \"in steter Furcht vor Menschen und Tieren, eine Beute\r\nder Hunde, der Adler, ja fast aller Raubtiere! Unsere stete Angst ist ärger\r\nals der Tod selbst. Auf, laßt uns ein für allemal sterben.\"\r\n

In einem nahen Teich wollten sie sich nun ersäufen; sie eilten\r\nihm zu; allein das außerordentliche Getöse und ihre wunderbare\r\nGestalt erschreckte eine Menge Frösche, die am Ufer saßen, so\r\nsehr, daß sie aufs schnellste untertauchten.\r\n

\"Halt\", rief nun eben dieser Sprecher, \"wir wollen das Ersäufen\r\nnoch ein wenig aufschieben, denn auch uns fürchten, wie ihr seht,\r\neinige Tiere, welche also wohl noch unglücklicher sein müssen\r\nals wir.\"\r\n

\"red\r\n\r" @@ -242,18 +248,26 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= "attachments": [ { "Binary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "C:TEMPnsmailV0.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png" } }, - "content_id": "part1.39236103.1B697A54@example.com", - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png" + "content_id": { + "Text": "part1.39236103.1B697A54@example.com" + }, + "content_transfer_encoding": { + "Text": "base64" + }, + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "C:TEMPnsmailV0.png" + } + } } }, "contents": [ @@ -1587,18 +1601,26 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "Binary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "C:TEMPnsmailNM.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png" } }, - "content_id": "part2.39236103.1B697A54@example.com", - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png" + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "C:TEMPnsmailNM.png" + } + } + }, + "content_id": { + "Text": "part2.39236103.1B697A54@example.com" + }, + "content_transfer_encoding": { + "Text": "base64" } }, "contents": [ @@ -3060,19 +3082,25 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "InlineBinary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "greenball.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "greenball.png" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "greenball.png" + "content_transfer_encoding": { + "Text": "base64" + }, + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "greenball.png" + } } } }, @@ -4380,19 +4408,25 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "InlineBinary": { - "header": { + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "blueball.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "blueball.png" + } } }, - "content_transfer_encoding": "base64", "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } } }, diff --git a/tests/legacy/040.txt b/tests/legacy/040.txt index d5e8b34..d65060b 100644 --- a/tests/legacy/040.txt +++ b/tests/legacy/040.txt @@ -29,48 +29,52 @@ n wenig aufschieben, denn auch uns f=FCrchten, wie ihr seht, einige Tiere= ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 23, - "minute": 41, - "second": 7, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 - }, - "from": { - "Address": { - "name": "Doug Sauder", - "address": "dwsauder@example.com" + "headers": { + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } }, - "message_id": "39236653.CAA8A090@example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 23, + "minute": 41, + "second": 7, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "message_id": { + "Text": "39236653.CAA8A090@example.com" + }, "to": { "Address": { "name": "Jürgen Schmürgen", "address": "schmuergen@example.com" } }, - "content_transfer_encoding": "quoted-printable", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" - } + "subject": { + "Text": "Die Hasen und die Frösche" }, - "others": { - "X-Accept-Language": [ - "en" - ], - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ] + "mime_version": { + "Text": "1.0" + }, + "content_transfer_encoding": { + "Text": "quoted-printable" + }, + "from": { + "Address": { + "name": "Doug Sauder", + "address": "dwsauder@example.com" + } } }, "html_body": [ diff --git a/tests/legacy/041.txt b/tests/legacy/041.txt index ddb5614..5703f55 100644 --- a/tests/legacy/041.txt +++ b/tests/legacy/041.txt @@ -58,17 +58,19 @@ vAAAAABJRU5ErkJggg== ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 10, - "minute": 23, - "second": 16, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 10, + "minute": 23, + "second": 16, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } }, "from": { "Address": { @@ -76,20 +78,28 @@ vAAAAABJRU5ErkJggg== "address": "doug@penguin.example.com" } }, - "message_id": "Pine.LNX.4.21.0005191019440.8452-101000@penguin.example.com", - "mime_version": "1.0", - "subject": "PNG graphic", + "subject": { + "Text": "PNG graphic" + }, + "mime_version": { + "Text": "1.0" + }, "to": { "Address": { "name": "Heinz Müller", "address": "mueller@example.com" } }, + "message_id": { + "Text": "Pine.LNX.4.21.0005191019440.8452-101000@penguin.example.com" + }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "-1463757054-170444605-958746196=:8452" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "-1463757054-170444605-958746196=:8452" + } } } }, @@ -100,12 +110,14 @@ vAAAAABJRU5ErkJggg== ], "text_body": [ { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "US-ASCII" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "US-ASCII" + } } } }, @@ -115,22 +127,32 @@ vAAAAABJRU5ErkJggg== "attachments": [ { "Binary": { - "header": { - "content_description": "red ball", - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "redball.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "application", + "c_subtype": "octet-stream", + "attributes": { + "name": "redball.png" + } } }, - "content_id": "Pine.LNX.4.21.0005191023160.8452@penguin.example.com", - "content_transfer_encoding": "BASE64", - "content_type": { - "c_type": "application", - "c_subtype": "octet-stream", - "attributes": { - "name": "redball.png" + "content_description": { + "Text": "red ball" + }, + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "redball.png" + } } + }, + "content_id": { + "Text": "Pine.LNX.4.21.0005191023160.8452@penguin.example.com" + }, + "content_transfer_encoding": { + "Text": "BASE64" } }, "contents": [ diff --git a/tests/legacy/042.txt b/tests/legacy/042.txt index 826a13e..4f60dbd 100644 --- a/tests/legacy/042.txt +++ b/tests/legacy/042.txt @@ -59,17 +59,40 @@ Birds of a feather flock together. ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "to": { + "Address": { + "name": "Joe Blow", + "address": "blow@example.com" + } + }, + "subject": { + "Text": "Test message from Netscape Communicator 4.7" + }, + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "------------77060D866A66DC8D0921E051" + } + } + }, + "message_id": { + "Text": "3923686C.99FB5E36@example.com" + }, "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 23, - "minute": 50, - "second": 4, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 23, + "minute": 50, + "second": 4, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } }, "from": { "Address": { @@ -77,29 +100,8 @@ Birds of a feather flock together. "address": "dwsauder@example.com" } }, - "message_id": "3923686C.99FB5E36@example.com", - "mime_version": "1.0", - "subject": "Test message from Netscape Communicator 4.7", - "to": { - "Address": { - "name": "Joe Blow", - "address": "blow@example.com" - } - }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "------------77060D866A66DC8D0921E051" - } - }, - "others": { - "X-Accept-Language": [ - "en" - ], - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ] + "mime_version": { + "Text": "1.0" } }, "html_body": [ @@ -109,14 +111,18 @@ Birds of a feather flock together. ], "text_body": [ { - "header": { - "content_transfer_encoding": "7bit", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } + }, + "content_transfer_encoding": { + "Text": "7bit" } }, "contents": "\r\nThe Hare and the Tortoise \r\n \r\nA HARE one day ridiculed the short feet and slow pace of the Tortoise,\r\nwho replied, laughing: \"Though you be swift as the wind, I will beat\r\nyou in a race.\" The Hare, believing her assertion to be simply\r\nimpossible, assented to the proposal; and they agreed that the Fox\r\nshould choose the course and fix the goal. On the day appointed for the\r\nrace the two started together. The Tortoise never for a moment stopped,\r\nbut went on with a slow but steady pace straight to the end of the\r\ncourse. The Hare, lying down by the wayside, fell fast asleep. At last\r\nwaking up, and moving as fast as he could, he saw the Tortoise had\r\nreached the goal, and was comfortably dozing after her fatigue. \r\n \r\nSlow but steady wins the race.\r" @@ -125,20 +131,26 @@ Birds of a feather flock together. "attachments": [ { "Text": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "farmerandstork.txt" + "headers": { + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii", + "name": "farmerandstork.txt" + } } }, - "content_transfer_encoding": "7bit", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii", - "name": "farmerandstork.txt" + "content_transfer_encoding": { + "Text": "7bit" + }, + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "farmerandstork.txt" + } } } }, diff --git a/tests/legacy/043.txt b/tests/legacy/043.txt index bc36213..1e94430 100644 --- a/tests/legacy/043.txt +++ b/tests/legacy/043.txt @@ -62,17 +62,31 @@ als wir." ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "to": { + "Address": { + "name": "Heinz Müller", + "address": "mueller@example.com" + } + }, + "message_id": { + "Text": "392359CF.DFF4527@example.com" + }, + "subject": { + "Text": "Die Hasen und die Frösche (Netscape Communicator 4.7)" + }, "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 22, - "minute": 47, - "second": 43, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 22, + "minute": 47, + "second": 43, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } }, "from": { "Address": { @@ -80,41 +94,33 @@ als wir." "address": "dwsauder@example.com" } }, - "message_id": "392359CF.DFF4527@example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche (Netscape Communicator 4.7)", - "to": { - "Address": { - "name": "Heinz Müller", - "address": "mueller@example.com" - } - }, "content_type": { - "c_type": "multipart", - "c_subtype": "alternative", - "attributes": { - "boundary": "------------9D454F23DA86BCD63FA3805F" + "ContentType": { + "c_type": "multipart", + "c_subtype": "alternative", + "attributes": { + "boundary": "------------9D454F23DA86BCD63FA3805F" + } } }, - "others": { - "X-Accept-Language": [ - "en" - ], - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ] + "mime_version": { + "Text": "1.0" } }, "html_body": [ { - "header": { - "content_transfer_encoding": "7bit", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "us-ascii" + } } + }, + "content_transfer_encoding": { + "Text": "7bit" } }, "contents": "\r\n\r\nDie Hasen und die Frösche\r\n

Die Hasen klagten einst über ihre mißliche Lage; \"wir leben\",\r\nsprach ein Redner, \"in steter Furcht vor Menschen und Tieren, eine Beute\r\nder Hunde, der Adler, ja fast aller Raubtiere! Unsere stete Angst ist ärger\r\nals der Tod selbst. Auf, laßt uns ein für allemal sterben.\"\r\n

In einem nahen Teich wollten sie sich nun ersäufen; sie eilten\r\nihm zu; allein das außerordentliche Getöse und ihre wunderbare\r\nGestalt erschreckte eine Menge Frösche, die am Ufer saßen, so\r\nsehr, daß sie aufs schnellste untertauchten.\r\n

\"Halt\", rief nun eben dieser Sprecher, \"wir wollen das Ersäufen\r\nnoch ein wenig aufschieben, denn auch uns fürchten, wie ihr seht,\r\neinige Tiere, welche also wohl noch unglücklicher sein müssen\r\nals wir.\"\r\n
 \r\n
 \r\n\r" @@ -122,14 +128,18 @@ als wir." ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "Die Hasen und die Frösche\n\nDie Hasen klagten einst über ihre mißliche Lage; \"wir leben\", sprach ein\nRedner, \"in steter Furcht vor Menschen und Tieren, eine Beute der Hunde,\nder Adler, ja fast aller Raubtiere! Unsere stete Angst ist ärger als der\nTod selbst. Auf, laßt uns ein für allemal sterben.\"\n\nIn einem nahen Teich wollten sie sich nun ersäufen; sie eilten ihm zu;\nallein das außerordentliche Getöse und ihre wunderbare Gestalt\nerschreckte eine Menge Frösche, die am Ufer saßen, so sehr, daß sie aufs\nschnellste untertauchten.\n\n\"Halt\", rief nun eben dieser Sprecher, \"wir wollen das Ersäufen noch ein\nwenig aufschieben, denn auch uns fürchten, wie ihr seht, einige Tiere,\nwelche also wohl noch unglücklicher sein müssen als wir.\"\n\n\n" diff --git a/tests/legacy/044.txt b/tests/legacy/044.txt index b6b2fd1..aebe518 100644 --- a/tests/legacy/044.txt +++ b/tests/legacy/044.txt @@ -138,17 +138,15 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 23, - "minute": 6, - "second": 4, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "mime_version": { + "Text": "1.0" + }, + "to": { + "Address": { + "name": "Joe Blow", + "address": "blow@example.com" + } }, "from": { "Address": { @@ -156,29 +154,33 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= "address": "dwsauder@example.com" } }, - "message_id": "39235E1C.1DC7EA90@example.com", - "mime_version": "1.0", - "subject": "Test message from Netscape Communicator 4.7", - "to": { - "Address": { - "name": "Joe Blow", - "address": "blow@example.com" - } + "subject": { + "Text": "Test message from Netscape Communicator 4.7" }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "------------A1FCDEE154E03D875E5D6779" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "------------A1FCDEE154E03D875E5D6779" + } } }, - "others": { - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ], - "X-Accept-Language": [ - "en" - ] + "message_id": { + "Text": "39235E1C.1DC7EA90@example.com" + }, + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 23, + "minute": 6, + "second": 4, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } } }, "html_body": [ @@ -191,14 +193,18 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "Die Hasen und die Frösche\n\nDie Hasen klagten einst über ihre mißliche Lage; \"wir leben\", sprach ein\nRedner, \"in steter Furcht vor Menschen und Tieren, eine Beute der Hunde,\nder Adler, ja fast aller Raubtiere! Unsere stete Angst ist ärger als der\nTod selbst. Auf, laßt uns ein für allemal sterben.\"\n\nIn einem nahen Teich wollten sie sich nun ersäufen; sie eilten ihm zu;\nallein das außerordentliche Getöse und ihre wunderbare Gestalt\nerschreckte eine Menge Frösche, die am Ufer saßen, so sehr, daß sie aufs\nschnellste untertauchten.\n\n\"Halt\", rief nun eben dieser Sprecher, \"wir wollen das Ersäufen noch ein\nwenig aufschieben, denn auch uns fürchten, wie ihr seht, einige Tiere,\nwelche also wohl noch unglücklicher sein müssen als wir.\"\n\n\n" @@ -210,19 +216,25 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= "attachments": [ { "InlineBinary": { - "header": { + "headers": { "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "redball.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "redball.png" + } } }, - "content_transfer_encoding": "base64", + "content_transfer_encoding": { + "Text": "base64" + }, "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "redball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "redball.png" + } } } }, @@ -1685,19 +1697,25 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "InlineBinary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "greenball.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "greenball.png" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "greenball.png" + "content_transfer_encoding": { + "Text": "base64" + }, + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "greenball.png" + } } } }, @@ -3005,19 +3023,25 @@ eSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "InlineBinary": { - "header": { + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "blueball.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "blueball.png" + } } }, - "content_transfer_encoding": "base64", "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } } }, diff --git a/tests/legacy/045.txt b/tests/legacy/045.txt index 6a8cec3..dedb176 100644 --- a/tests/legacy/045.txt +++ b/tests/legacy/045.txt @@ -43,17 +43,15 @@ bGljaGVyIHNlaW4gbfxzc2VuIGFscyB3aXIuIiANDQoNDQo= ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 10, - "minute": 26, - "second": 12, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "-1463757054-891160829-958746372=:8452" + } + } }, "from": { "Address": { @@ -61,9 +59,12 @@ bGljaGVyIHNlaW4gbfxzc2VuIGFscyB3aXIuIiANDQoNDQo= "address": "doug@penguin.example.com" } }, - "message_id": "Pine.LNX.4.21.0005191024380.8452-200000@penguin.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", + "message_id": { + "Text": "Pine.LNX.4.21.0005191024380.8452-200000@penguin.example.com" + }, + "subject": { + "Text": "Die Hasen und die Frösche" + }, "to": { "AddressList": [ { @@ -76,12 +77,21 @@ bGljaGVyIHNlaW4gbfxzc2VuIGFscyB3aXIuIiANDQoNDQo= } ] }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "-1463757054-891160829-958746372=:8452" + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 10, + "minute": 26, + "second": 12, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 } + }, + "mime_version": { + "Text": "1.0" } }, "html_body": [ @@ -91,12 +101,14 @@ bGljaGVyIHNlaW4gbfxzc2VuIGFscyB3aXIuIiANDQoNDQo= ], "text_body": [ { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "US-ASCII" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "US-ASCII" + } } } }, @@ -106,23 +118,33 @@ bGljaGVyIHNlaW4gbfxzc2VuIGFscyB3aXIuIiANDQoNDQo= "attachments": [ { "Text": { - "header": { - "content_description": "Short story in German", - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "HasenundFrösche.txt" + "headers": { + "content_description": { + "Text": "Short story in German" + }, + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1", + "name": "HasenundFrösche.txt" + } } }, - "content_id": "Pine.LNX.4.21.0005191026120.8452@penguin.example.com", - "content_transfer_encoding": "BASE64", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1", - "name": "HasenundFrösche.txt" + "content_transfer_encoding": { + "Text": "BASE64" + }, + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "HasenundFrösche.txt" + } } + }, + "content_id": { + "Text": "Pine.LNX.4.21.0005191026120.8452@penguin.example.com" } }, "contents": "Die Hasen und die Frösche\r\r\n\r\r\nDie Hasen klagten einst über ihre mißliche Lage; \"wir leben\", sprach ein Redner, \"in steter Furcht vor Menschen und Tieren, eine Beute der Hunde, der Adler, ja fast aller Raubtiere! Unsere stete Angst ist ärger als der Tod selbst. Auf, laßt uns ein für allemal sterben.\" \r\r\n\r\r\nIn einem nahen Teich wollten sie sich nun ersäufen; sie eilten ihm zu; allein das außerordentliche Getöse und ihre wunderbare Gestalt erschreckte eine Menge Frösche, die am Ufer saßen, so sehr, daß sie aufs schnellste untertauchten. \r\r\n\r\r\n\"Halt\", rief nun eben dieser Sprecher, \"wir wollen das Ersäufen noch ein wenig aufschieben, denn auch uns fürchten, wie ihr seht, einige Tiere, welche also wohl noch unglücklicher sein müssen als wir.\" \r\r\n\r\r\n" diff --git a/tests/legacy/046.txt b/tests/legacy/046.txt index e6372d3..cabff5c 100644 --- a/tests/legacy/046.txt +++ b/tests/legacy/046.txt @@ -33,48 +33,52 @@ welche also wohl noch ungl=FCcklicher sein m=FCssen als wir." ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 22, - "minute": 31, - "second": 57, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 - }, - "from": { - "Address": { - "name": "Doug Sauder", - "address": "dwsauder@example.com" + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 22, + "minute": 31, + "second": 57, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 } }, - "message_id": "3923561C.B7078DEF@example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche (Netscape Communicator 4.7)", + "mime_version": { + "Text": "1.0" + }, + "subject": { + "Text": "Die Hasen und die Frösche (Netscape Communicator 4.7)" + }, "to": { "Address": { "name": "Jürgen Schmürgen", "address": "schmuergen@example.com" } }, - "content_transfer_encoding": "quoted-printable", "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } }, - "others": { - "X-Accept-Language": [ - "en" - ], - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ] + "content_transfer_encoding": { + "Text": "quoted-printable" + }, + "message_id": { + "Text": "3923561C.B7078DEF@example.com" + }, + "from": { + "Address": { + "name": "Doug Sauder", + "address": "dwsauder@example.com" + } } }, "html_body": [ diff --git a/tests/legacy/047.txt b/tests/legacy/047.txt index a823235..0009e15 100644 --- a/tests/legacy/047.txt +++ b/tests/legacy/047.txt @@ -61,17 +61,15 @@ n wenig aufschieben, denn auch uns f=FCrchten, wie ihr seht, einige Tiere= ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 23, - "minute": 47, - "second": 8, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "------------CA611088711119FBDB3473B4" + } + } }, "from": { "Address": { @@ -79,29 +77,33 @@ n wenig aufschieben, denn auch uns f=FCrchten, wie ihr seht, einige Tiere= "address": "dwsauder@example.com" } }, - "message_id": "392367BC.3D075C95@example.com", - "mime_version": "1.0", - "subject": "Test message from Netscape Communicator 4.7", "to": { "Address": { "name": "Joe Blow", "address": "blow@example.com" } }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "------------CA611088711119FBDB3473B4" - } + "subject": { + "Text": "Test message from Netscape Communicator 4.7" }, - "others": { - "X-Accept-Language": [ - "en" - ], - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ] + "message_id": { + "Text": "392367BC.3D075C95@example.com" + }, + "mime_version": { + "Text": "1.0" + }, + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 23, + "minute": 47, + "second": 8, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } } }, "html_body": [ @@ -111,13 +113,17 @@ n wenig aufschieben, denn auch uns f=FCrchten, wie ihr seht, einige Tiere= ], "text_body": [ { - "header": { - "content_transfer_encoding": "7bit", + "headers": { + "content_transfer_encoding": { + "Text": "7bit" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } } }, @@ -127,21 +133,27 @@ n wenig aufschieben, denn auch uns f=FCrchten, wie ihr seht, einige Tiere= "attachments": [ { "Text": { - "header": { + "headers": { "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "HasenundFrösche.txt" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "HasenundFrösche.txt" + } } }, - "content_transfer_encoding": "quoted-printable", "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "name": "HasenundFrösche.txt", - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1", + "name": "HasenundFrösche.txt" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "Die Hasen und die Frösche\n\nDie Hasen klagten einst über ihre mißliche Lage; \"wir leben\", sprach ein Redner, \"in steter Furcht vor Menschen und Tieren, eine Beute der Hunde, der Adler, ja fast aller Raubtiere! Unsere stete Angst ist ärger als der Tod selbst. Auf, laßt uns ein für allemal sterben.\" \n\nIn einem nahen Teich wollten sie sich nun ersäufen; sie eilten ihm zu; allein das außerordentliche Getöse und ihre wunderbare Gestalt erschreckte eine Menge Frösche, die am Ufer saßen, so sehr, daß sie aufs schnellste untertauchten. \n\n\"Halt\", rief nun eben dieser Sprecher, \"wir wollen das Ersäufen noch ein wenig aufschieben, denn auch uns fürchten, wie ihr seht, einige Tiere, welche also wohl noch unglücklicher sein müssen als wir.\" \n\n" diff --git a/tests/legacy/048.txt b/tests/legacy/048.txt index a605894..27cf9eb 100644 --- a/tests/legacy/048.txt +++ b/tests/legacy/048.txt @@ -156,47 +156,49 @@ end ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 23, - "minute": 44, - "second": 12, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "subject": { + "Text": "Test message from Netscape Communicator 4.7" }, - "from": { - "Address": { - "name": "Doug Sauder", - "address": "dwsauder@example.com" + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "------------177483472E7788F4AD46AB1A" + } } }, - "message_id": "3923670C.67D83A99@example.com", - "mime_version": "1.0", - "subject": "Test message from Netscape Communicator 4.7", "to": { "Address": { "name": "Joe Blow", "address": "blow@example.com" } }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "------------177483472E7788F4AD46AB1A" + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 23, + "minute": 44, + "second": 12, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 } }, - "others": { - "X-Mailer": [ - "Mozilla 4.7 [en] (WinNT; I)" - ], - "X-Accept-Language": [ - "en" - ] + "message_id": { + "Text": "3923670C.67D83A99@example.com" + }, + "mime_version": { + "Text": "1.0" + }, + "from": { + "Address": { + "name": "Doug Sauder", + "address": "dwsauder@example.com" + } } }, "html_body": [ @@ -209,13 +211,17 @@ end ], "text_body": [ { - "header": { - "content_transfer_encoding": "7bit", + "headers": { + "content_transfer_encoding": { + "Text": "7bit" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } } }, @@ -228,19 +234,25 @@ end "attachments": [ { "InlineBinary": { - "header": { + "headers": { + "content_transfer_encoding": { + "Text": "x-uuencode" + }, "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "redball.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "redball.png" + } } }, - "content_transfer_encoding": "x-uuencode", "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "redball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "redball.png" + } } } }, @@ -2318,19 +2330,25 @@ end }, { "InlineBinary": { - "header": { + "headers": { "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "greenball.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "greenball.png" + } } }, - "content_transfer_encoding": "x-uuencode", + "content_transfer_encoding": { + "Text": "x-uuencode" + }, "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "greenball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "greenball.png" + } } } }, @@ -4190,19 +4208,25 @@ end }, { "InlineBinary": { - "header": { + "headers": { + "content_transfer_encoding": { + "Text": "x-uuencode" + }, "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "blueball.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "blueball.png" + } } }, - "content_transfer_encoding": "x-uuencode", "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } } }, diff --git a/tests/legacy/049.txt b/tests/legacy/049.txt index db3b012..3f9ba5c 100644 --- a/tests/legacy/049.txt +++ b/tests/legacy/049.txt @@ -132,17 +132,18 @@ end ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 58, - "second": 13, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGIEKGCHAA.doug@example.com" + }, + "to": { + "Address": { + "name": "Joe Blow", + "address": "jblow@example.com" + } + }, + "subject": { + "Text": "Test message from Microsoft Outlook 00" }, "from": { "Address": { @@ -150,30 +151,18 @@ end "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGIEKGCHAA.doug@example.com", - "subject": "Test message from Microsoft Outlook 00", - "to": { - "Address": { - "name": "Joe Blow", - "address": "jblow@example.com" + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 58, + "second": 13, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 } - }, - "others": { - "X-Priority": [ - "3 (Normal)" - ], - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "X-MSMail-Priority": [ - "Normal" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ], - "Importance": [ - "Normal" - ] } }, "html_body": [ diff --git a/tests/legacy/050.txt b/tests/legacy/050.txt index e689bd0..6d49c0e 100644 --- a/tests/legacy/050.txt +++ b/tests/legacy/050.txt @@ -110,17 +110,41 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "to": { + "Address": { + "name": "Heinz Müller", + "address": "mueller@example.com" + } + }, "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 0, - "minute": 39, - "second": 36, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 0, + "minute": 39, + "second": 36, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "subject": { + "Text": "Die Hasen und die Frösche" + }, + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "related", + "attributes": { + "boundary": "=====================_715546120==_.REL", + "type": "text/html" + } + } + }, + "message_id": { + "Text": "4.2.0.58.20000519003934.00a866f0@pop.example.com" }, "from": { "Address": { @@ -128,44 +152,23 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519003934.00a866f0@pop.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", - "to": { - "Address": { - "name": "Heinz Müller", - "address": "mueller@example.com" - } - }, - "content_type": { - "c_type": "multipart", - "c_subtype": "related", - "attributes": { - "type": "text/html", - "boundary": "=====================_715546120==_.REL" - } - }, - "others": { - "X-Priority": [ - "2 (High)" - ], - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ], - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ] + "mime_version": { + "Text": "1.0" } }, "html_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { + "content_transfer_encoding": { + "Text": "quoted-printable" + }, "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "iso-8859-1" + } } } }, @@ -180,21 +183,29 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== "attachments": [ { "Binary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "2aa658b6.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "2aa658b6.png" + } } }, - "content_id": "4.2.0.58.20000519003934.00a866f0@pop.example.com.2", - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "2aa658b6.png" + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "2aa658b6.png" + } } + }, + "content_transfer_encoding": { + "Text": "base64" + }, + "content_id": { + "Text": "4.2.0.58.20000519003934.00a866f0@pop.example.com.2" } }, "contents": [ @@ -1528,21 +1539,29 @@ IFl2ZXMgUGlndWV0NnM7vAAAAABJRU5ErkJggg== }, { "Binary": { - "header": { + "headers": { "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "2aa658c0.png" + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "2aa658c0.png" + } } }, - "content_id": "4.2.0.58.20000519003934.00a866f0@pop.example.com.3", - "content_transfer_encoding": "base64", "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "2aa658c0.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "2aa658c0.png" + } } + }, + "content_transfer_encoding": { + "Text": "base64" + }, + "content_id": { + "Text": "4.2.0.58.20000519003934.00a866f0@pop.example.com.3" } }, "contents": [ diff --git a/tests/legacy/051.txt b/tests/legacy/051.txt index 7fa3d63..70f14ed 100644 --- a/tests/legacy/051.txt +++ b/tests/legacy/051.txt @@ -162,17 +162,21 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 19, - "hour": 0, - "minute": 39, - "second": 5, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "subject": { + "Text": "Die Hasen und die Frösche" + }, + "mime_version": { + "Text": "1.0" + }, + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "=====================_715515186==_" + } + } }, "from": { "Address": { @@ -180,32 +184,27 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= "address": "dwsauder@example.com" } }, - "message_id": "4.2.0.58.20000519003903.00a859b0@pop.example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche", + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 19, + "hour": 0, + "minute": 39, + "second": 5, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "message_id": { + "Text": "4.2.0.58.20000519003903.00a859b0@pop.example.com" + }, "to": { "Address": { "name": "Heinz Müller", "address": "mueller@example.com" } - }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "=====================_715515186==_" - } - }, - "others": { - "X-Mailer": [ - "QUALCOMM Windows Eudora Pro Version 4.2.0.58" - ], - "X-Priority": [ - "2 (High)" - ], - "X-Sender": [ - "dwsauder@pop.example.com (Unverified)" - ] } }, "html_body": [ @@ -215,14 +214,18 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "iso-8859-1" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "iso-8859-1" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "Die Hasen und die Frösche\n\nDie Hasen klagten einst über ihre mißliche Lage; \"wir leben\", sprach ein Redner, \"in steter Furcht vor Menschen und Tieren, eine Beute der Hunde, der Adler, ja fast aller Raubtiere! Unsere stete Angst ist ärger als der Tod selbst. Auf, laßt uns ein für allemal sterben.\" \n\nIn einem nahen Teich wollten sie sich nun ersäufen; sie eilten ihm zu; allein das außerordentliche Getöse und ihre wunderbare Gestalt erschreckte eine Menge Frösche, die am Ufer saßen, so sehr, daß sie aufs schnellste untertauchten. \n\n\"Halt\", rief nun eben dieser Sprecher, \"wir wollen das Ersäufen noch ein wenig aufschieben, denn auch uns fürchten, wie ihr seht, einige Tiere, welche also wohl noch unglücklicher sein müssen als wir.\" \n\n2aa5e03a.png2aa5e044.png" @@ -231,20 +234,28 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= "attachments": [ { "Binary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "2aa5e03a.png" + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, + "content_id": { + "Text": "4.2.0.58.20000519003903.00a859b0@pop.example.com.2" + }, + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "2aa5e03a.png" + } } }, - "content_id": "4.2.0.58.20000519003903.00a859b0@pop.example.com.2", - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "2aa5e03a.png" + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "2aa5e03a.png" + } } } }, @@ -1579,20 +1590,28 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "Binary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "filename": "2aa5e044.png" + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, + "content_id": { + "Text": "4.2.0.58.20000519003903.00a859b0@pop.example.com.3" + }, + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "2aa5e044.png" + } } }, - "content_id": "4.2.0.58.20000519003903.00a859b0@pop.example.com.3", - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "2aa5e044.png" + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "filename": "2aa5e044.png" + } } } }, @@ -3055,19 +3074,25 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "Binary": { - "header": { - "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "blueball.png" + "headers": { + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "blueball.png" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "blueball.png" + "content_transfer_encoding": { + "Text": "base64" + }, + "content_disposition": { + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "blueball.png" + } } } }, @@ -4402,19 +4427,25 @@ bGlwMmdpZiB2LjAuNiBieSBZdmVzIFBpZ3VldDZzO7wAAAAASUVORK5CYII= }, { "Binary": { - "header": { + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, "content_disposition": { - "c_type": "attachment", - "attributes": { - "filename": "greenball.png" + "ContentType": { + "c_type": "attachment", + "attributes": { + "filename": "greenball.png" + } } }, - "content_transfer_encoding": "base64", "content_type": { - "c_type": "image", - "c_subtype": "png", - "attributes": { - "name": "greenball.png" + "ContentType": { + "c_type": "image", + "c_subtype": "png", + "attributes": { + "name": "greenball.png" + } } } }, diff --git a/tests/legacy/052.txt b/tests/legacy/052.txt index 38b5f0d..3844dda 100644 --- a/tests/legacy/052.txt +++ b/tests/legacy/052.txt @@ -28,48 +28,37 @@ welche also wohl noch ungl ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 28, - "second": 40, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGOEKDCHAA.doug@example.com" }, - "from": { - "Address": { - "name": "Doug Sauder", - "address": "doug@example.com" + "subject": { + "Text": "Die Hasen und die Fr�sche (Microsoft Outlook 00)" + }, + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 28, + "second": 40, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 } }, - "message_id": "NDBBIAKOPKHFGPLCODIGOEKDCHAA.doug@example.com", - "subject": "Die Hasen und die Fr�sche (Microsoft Outlook 00)", "to": { "Address": { "name": "Heinz M�ller", "address": "mueller@example.com" } }, - "others": { - "X-MSMail-Priority": [ - "Normal" - ], - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ], - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "Importance": [ - "Normal" - ], - "X-Priority": [ - "3 (Normal)" - ] + "from": { + "Address": { + "name": "Doug Sauder", + "address": "doug@example.com" + } } }, "html_body": [ diff --git a/tests/legacy/053.txt b/tests/legacy/053.txt index 6e87883..be38572 100644 --- a/tests/legacy/053.txt +++ b/tests/legacy/053.txt @@ -33,17 +33,9 @@ als wir."=20 ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2000, - "month": 5, - "day": 17, - "hour": 19, - "minute": 27, - "second": 4, - "tz_before_gmt": true, - "tz_hour": 4, - "tz_minute": 0 + "headers": { + "content_transfer_encoding": { + "Text": "quoted-printable" }, "from": { "Address": { @@ -51,39 +43,42 @@ als wir."=20 "address": "doug@example.com" } }, - "message_id": "NDBBIAKOPKHFGPLCODIGKEKDCHAA.doug@example.com", - "mime_version": "1.0", - "subject": "Die Hasen und die Frösche (Microsoft Outlook 00)", + "date": { + "DateTime": { + "year": 2000, + "month": 5, + "day": 17, + "hour": 19, + "minute": 27, + "second": 4, + "tz_before_gmt": true, + "tz_hour": 4, + "tz_minute": 0 + } + }, + "message_id": { + "Text": "NDBBIAKOPKHFGPLCODIGKEKDCHAA.doug@example.com" + }, + "subject": { + "Text": "Die Hasen und die Frösche (Microsoft Outlook 00)" + }, + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "utf-8" + } + } + }, "to": { "Address": { "name": "Heinz Müller", "address": "mueller@example.com" } }, - "content_transfer_encoding": "quoted-printable", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "utf-8" - } - }, - "others": { - "X-MimeOLE": [ - "Produced By Microsoft MimeOLE V5.00.2314.1300" - ], - "X-MSMail-Priority": [ - "Normal" - ], - "X-Mailer": [ - "Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)" - ], - "Importance": [ - "Normal" - ], - "X-Priority": [ - "3 (Normal)" - ] + "mime_version": { + "Text": "1.0" } }, "html_body": [ diff --git a/tests/malformed/000.txt b/tests/malformed/000.txt index c332dfe..6a3acff 100644 --- a/tests/malformed/000.txt +++ b/tests/malformed/000.txt @@ -11,12 +11,14 @@ Content-Type: text/html ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": ":foo" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": ":foo" + } } } } diff --git a/tests/malformed/001.txt b/tests/malformed/001.txt index 98231be..41a0dfd 100644 --- a/tests/malformed/001.txt +++ b/tests/malformed/001.txt @@ -11,12 +11,14 @@ Content-Type: text/plain ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "ab" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "ab" + } } } }, diff --git a/tests/malformed/002.txt b/tests/malformed/002.txt index dd9fed9..9d47f48 100644 --- a/tests/malformed/002.txt +++ b/tests/malformed/002.txt @@ -4,12 +4,14 @@ body ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "ab" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "ab" + } } } }, diff --git a/tests/malformed/003.txt b/tests/malformed/003.txt index 377c9a5..5e8c34b 100644 --- a/tests/malformed/003.txt +++ b/tests/malformed/003.txt @@ -10,22 +10,26 @@ body ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "a" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "a" + } } } }, "attachments": [ { "Text": { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "body\n" diff --git a/tests/malformed/004.txt b/tests/malformed/004.txt index 0502e2a..2362c29 100644 --- a/tests/malformed/004.txt +++ b/tests/malformed/004.txt @@ -10,12 +10,14 @@ body ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "a" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "a" + } } } }, diff --git a/tests/malformed/005.txt b/tests/malformed/005.txt index 6376645..f5c0c9e 100644 --- a/tests/malformed/005.txt +++ b/tests/malformed/005.txt @@ -14,12 +14,14 @@ body2 --a---- ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "a--" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "a--" + } } } }, @@ -30,10 +32,12 @@ body2 ], "text_body": [ { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "body" diff --git a/tests/malformed/006.txt b/tests/malformed/006.txt index a33d936..323be60 100644 --- a/tests/malformed/006.txt +++ b/tests/malformed/006.txt @@ -10,22 +10,26 @@ body ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "a" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "a" + } } } }, "attachments": [ { "Text": { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "body\n" diff --git a/tests/malformed/007.txt b/tests/malformed/007.txt index c202f63..3d709fe 100644 --- a/tests/malformed/007.txt +++ b/tests/malformed/007.txt @@ -12,12 +12,14 @@ Content-Type: text/plain ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "a" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "a" + } } } }, diff --git a/tests/malformed/008.txt b/tests/malformed/008.txt index 22afbcc..ba85dc5 100644 --- a/tests/malformed/008.txt +++ b/tests/malformed/008.txt @@ -14,22 +14,26 @@ body2 ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "ab" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "ab" + } } } }, "attachments": [ { "Text": { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "body\n--ab\nContent-Type: text/html\n\nbody2\n" diff --git a/tests/malformed/009.txt b/tests/malformed/009.txt index b54ca2f..7fd2709 100644 --- a/tests/malformed/009.txt +++ b/tests/malformed/009.txt @@ -18,12 +18,14 @@ Content-Type: text/plain ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "1" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "1" + } } } }, @@ -34,10 +36,12 @@ Content-Type: text/plain ], "text_body": [ { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "1" @@ -46,10 +50,12 @@ Content-Type: text/plain "attachments": [ { "Text": { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "22\n--1\nContent-Type: text/plain\n\n333\n" diff --git a/tests/malformed/010.txt b/tests/malformed/010.txt index 700139e..28a8760 100644 --- a/tests/malformed/010.txt +++ b/tests/malformed/010.txt @@ -8,28 +8,34 @@ Content-Type: text/plain ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "message", - "c_subtype": "rfc822" + "ContentType": { + "c_type": "message", + "c_subtype": "rfc822" + } } }, "attachments": [ { "Message": { - "header": { + "headers": { "content_type": { - "c_type": "message", - "c_subtype": "rfc822" + "ContentType": { + "c_type": "message", + "c_subtype": "rfc822" + } } }, "attachments": [ { "Message": { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "html_body": [ diff --git a/tests/malformed/011.txt b/tests/malformed/011.txt index b54ca2f..7fd2709 100644 --- a/tests/malformed/011.txt +++ b/tests/malformed/011.txt @@ -18,12 +18,14 @@ Content-Type: text/plain ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "1" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "1" + } } } }, @@ -34,10 +36,12 @@ Content-Type: text/plain ], "text_body": [ { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "1" @@ -46,10 +50,12 @@ Content-Type: text/plain "attachments": [ { "Text": { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "22\n--1\nContent-Type: text/plain\n\n333\n" diff --git a/tests/malformed/012.txt b/tests/malformed/012.txt index 5038485..b1a975f 100644 --- a/tests/malformed/012.txt +++ b/tests/malformed/012.txt @@ -24,22 +24,26 @@ Content-Type: text/plain ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "1" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "1" + } } } }, "attachments": [ { "Message": { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "html_body": [ @@ -56,10 +60,12 @@ Content-Type: text/plain }, { "Message": { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "attachments": [ diff --git a/tests/malformed/013.txt b/tests/malformed/013.txt index f2d8cb0..1e1c5a2 100644 --- a/tests/malformed/013.txt +++ b/tests/malformed/013.txt @@ -33,14 +33,18 @@ hello, world ---- EXPECTED STRUCTURE ---- { - "header": { - "mime_version": "1.0", + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "1" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "1" + } } + }, + "mime_version": { + "Text": "1.0" } }, "html_body": [ @@ -59,37 +63,45 @@ hello, world ], "text_body": [ { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "hello, world" }, { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "hello, world" }, { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "hello, world" }, { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "hello, world" diff --git a/tests/malformed/014.txt b/tests/malformed/014.txt index 2c4a334..5d3873c 100644 --- a/tests/malformed/014.txt +++ b/tests/malformed/014.txt @@ -8,12 +8,14 @@ hello, world ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "1" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "1" + } } } }, @@ -24,10 +26,12 @@ hello, world ], "text_body": [ { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "hello, world" diff --git a/tests/malformed/015.txt b/tests/malformed/015.txt index 0638034..a230bdc 100644 --- a/tests/malformed/015.txt +++ b/tests/malformed/015.txt @@ -26,30 +26,7 @@ invalid ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 2007, - "month": 5, - "day": 23, - "hour": 4, - "minute": 58, - "second": 8, - "tz_before_gmt": false, - "tz_hour": 3, - "tz_minute": 0 - }, - "from": { - "Address": { - "name": "Test User", - "address": "test@example.org" - } - }, - "message_id": "1.2.3.4@example", - "mime_version": "1.0", - "return_path": [ - "test@example.org" - ], - "subject": "Hello world", + "headers": { "to": { "Address": { "name": "Another User", @@ -57,13 +34,46 @@ invalid } }, "content_type": { - "c_type": "multipart", - "c_subtype": "signed", - "attributes": { - "boundary": "=-GNQXLhuj24Pl1aCkk4/d", - "protocol": "application/pgp-signature", - "micalg": "pgp-sha1" + "ContentType": { + "c_type": "multipart", + "c_subtype": "signed", + "attributes": { + "micalg": "pgp-sha1", + "protocol": "application/pgp-signature", + "boundary": "=-GNQXLhuj24Pl1aCkk4/d" + } } + }, + "return_path": { + "Text": "test@example.org" + }, + "mime_version": { + "Text": "1.0" + }, + "from": { + "Address": { + "name": "Test User", + "address": "test@example.org" + } + }, + "message_id": { + "Text": "1.2.3.4@example" + }, + "date": { + "DateTime": { + "year": 2007, + "month": 5, + "day": 23, + "hour": 4, + "minute": 58, + "second": 8, + "tz_before_gmt": false, + "tz_hour": 3, + "tz_minute": 0 + } + }, + "subject": { + "Text": "Hello world" } }, "html_body": [ @@ -73,11 +83,15 @@ invalid ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "There was a day \na happy day\n" @@ -86,12 +100,14 @@ invalid "attachments": [ { "Binary": { - "header": { + "headers": { "content_type": { - "c_type": "application", - "c_subtype": "pgp-signature", - "attributes": { - "name": "signature.asc" + "ContentType": { + "c_type": "application", + "c_subtype": "pgp-signature", + "attributes": { + "name": "signature.asc" + } } } }, diff --git a/tests/malformed/016.txt b/tests/malformed/016.txt index 7bb59bb..3672031 100644 --- a/tests/malformed/016.txt +++ b/tests/malformed/016.txt @@ -25,12 +25,14 @@ Content-Type: text/plain ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "1234567890123456789012345678901234567890123456789012345678901234567890123456789012" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "1234567890123456789012345678901234567890123456789012345678901234567890123456789012" + } } } }, @@ -41,10 +43,12 @@ Content-Type: text/plain ], "text_body": [ { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "1\n--1234567890123456789012345678901234567890123456789012345678901234567890123456789012\nContent-Type: text/plain\n\n22\n--123456789012345678901234567890123456789012345678901234567890123456789012345678901\nContent-Type: text/plain\n\n333" @@ -53,10 +57,12 @@ Content-Type: text/plain "attachments": [ { "Text": { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "4444\n" diff --git a/tests/rfc/000.txt b/tests/rfc/000.txt index 75abdf0..6eab450 100644 --- a/tests/rfc/000.txt +++ b/tests/rfc/000.txt @@ -73,17 +73,24 @@ Content-Transfer-Encoding: Quoted-printable ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 1994, - "month": 10, - "day": 7, - "hour": 16, - "minute": 15, - "second": 5, - "tz_before_gmt": true, - "tz_hour": 7, - "tz_minute": 0 + "headers": { + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "unique-boundary-1" + } + } + }, + "to": { + "Address": { + "name": "Ned Freed", + "address": "ned@innosoft.com" + } + }, + "mime_version": { + "Text": "1.0" }, "from": { "Address": { @@ -91,19 +98,20 @@ Content-Transfer-Encoding: Quoted-printable "address": "nsb@nsb.fv.com" } }, - "mime_version": "1.0", - "subject": "A multipart example", - "to": { - "Address": { - "name": "Ned Freed", - "address": "ned@innosoft.com" - } + "subject": { + "Text": "A multipart example" }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "unique-boundary-1" + "date": { + "DateTime": { + "year": 1994, + "month": 10, + "day": 7, + "hour": 16, + "minute": 15, + "second": 5, + "tz_before_gmt": true, + "tz_hour": 7, + "tz_minute": 0 } } }, @@ -120,12 +128,14 @@ Content-Transfer-Encoding: Quoted-printable "contents": "... Some text appears here ...\n\n[Note that the blank between the boundary and the start\nof the text in this part means no header fields were\ngiven and this is text in the US-ASCII character set.\nIt could have been done with explicit typing as in the\nnext part.]\n" }, { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "US-ASCII" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "US-ASCII" + } } } }, @@ -135,11 +145,15 @@ Content-Transfer-Encoding: Quoted-printable "attachments": [ { "Text": { - "header": { - "content_transfer_encoding": "base64", + "headers": { "content_type": { - "c_type": "audio", - "c_subtype": "basic" + "ContentType": { + "c_type": "audio", + "c_subtype": "basic" + } + }, + "content_transfer_encoding": { + "Text": "base64" } }, "contents": "... base64-encoded 8000 Hz single-channel\n mu-law-format audio data goes here ...\n" @@ -147,11 +161,15 @@ Content-Transfer-Encoding: Quoted-printable }, { "Text": { - "header": { - "content_transfer_encoding": "base64", + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, "content_type": { - "c_type": "image", - "c_subtype": "jpeg" + "ContentType": { + "c_type": "image", + "c_subtype": "jpeg" + } } }, "contents": "... base64-encoded image data goes here ...\n" @@ -159,10 +177,12 @@ Content-Transfer-Encoding: Quoted-printable }, { "Text": { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "enriched" + "ContentType": { + "c_type": "text", + "c_subtype": "enriched" + } } }, "contents": "This is enriched.\nas defined in RFC 1896\n\nIsn't it\ncool?\n" @@ -170,25 +190,31 @@ Content-Transfer-Encoding: Quoted-printable }, { "Message": { - "header": { + "headers": { + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "ISO-8859-1" + } + } + }, "from": { "Address": { "name": "mailbox in US-ASCII" } }, - "subject": "(subject in US-ASCII)", + "subject": { + "Text": "(subject in US-ASCII)" + }, "to": { "Address": { "name": "address in US-ASCII" } }, - "content_transfer_encoding": "Quoted-printable", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "ISO-8859-1" - } + "content_transfer_encoding": { + "Text": "Quoted-printable" } }, "html_body": [ diff --git a/tests/rfc/001.txt b/tests/rfc/001.txt index 1d0a42d..98a4900 100644 --- a/tests/rfc/001.txt +++ b/tests/rfc/001.txt @@ -41,43 +41,55 @@ get RFC-MIME.DOC ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "subject": { + "Text": "whatever" + }, + "mime_version": { + "Text": "1.0" + }, + "message_id": { + "Text": "id1@host.com" + }, + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "alternative", + "attributes": { + "boundary": "42" + } + } + }, "from": { "Address": { "name": "Whomever" } }, - "message_id": "id1@host.com", - "mime_version": "1.0", - "subject": "whatever", + "content_id": { + "Text": "id001@guppylake.bellcore.com" + }, "to": { "Address": { "name": "Someone" } - }, - "content_id": "id001@guppylake.bellcore.com", - "content_type": { - "c_type": "multipart", - "c_subtype": "alternative", - "attributes": { - "boundary": "42" - } } }, "attachments": [ { "Binary": { - "header": { + "headers": { "content_type": { - "c_type": "message", - "c_subtype": "external-body", - "attributes": { - "name": "BodyFormats.ps", - "mode": "image", - "access-type": "ANON-FTP", - "directory": "pub", - "expiration": "Fri, 14 Jun 1991 19:13:14 -0400 (EDT)", - "site": "thumper.bellcore.com" + "ContentType": { + "c_type": "message", + "c_subtype": "external-body", + "attributes": { + "name": "BodyFormats.ps", + "mode": "image", + "site": "thumper.bellcore.com", + "directory": "pub", + "access-type": "ANON-FTP", + "expiration": "Fri, 14 Jun 1991 19:13:14 -0400 (EDT)" + } } } }, @@ -166,15 +178,17 @@ get RFC-MIME.DOC }, { "Binary": { - "header": { + "headers": { "content_type": { - "c_type": "message", - "c_subtype": "external-body", - "attributes": { - "access-type": "local-file", - "name": "/u/nsb/writing/rfcs/RFC-MIME.ps", - "expiration": "Fri, 14 Jun 1991 19:13:14 -0400 (EDT)", - "site": "thumper.bellcore.com" + "ContentType": { + "c_type": "message", + "c_subtype": "external-body", + "attributes": { + "name": "/u/nsb/writing/rfcs/RFC-MIME.ps", + "expiration": "Fri, 14 Jun 1991 19:13:14 -0400 (EDT)", + "access-type": "local-file", + "site": "thumper.bellcore.com" + } } } }, @@ -263,14 +277,16 @@ get RFC-MIME.DOC }, { "Binary": { - "header": { + "headers": { "content_type": { - "c_type": "message", - "c_subtype": "external-body", - "attributes": { - "access-type": "mail-server", - "server": "listserv@bogus.bitnet", - "expiration": "Fri, 14 Jun 1991 19:13:14 -0400 (EDT)" + "ContentType": { + "c_type": "message", + "c_subtype": "external-body", + "attributes": { + "access-type": "mail-server", + "expiration": "Fri, 14 Jun 1991 19:13:14 -0400 (EDT)", + "server": "listserv@bogus.bitnet" + } } } }, diff --git a/tests/rfc/002.txt b/tests/rfc/002.txt index 51a6730..107312b 100644 --- a/tests/rfc/002.txt +++ b/tests/rfc/002.txt @@ -73,14 +73,10 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz ---- EXPECTED STRUCTURE ---- { - "header": { - "from": { - "Address": { - "name": "Al Gore", - "address": "vice-president@whitehouse.gov" - } + "headers": { + "subject": { + "Text": "[Fwd: Map of Argentina with Description]" }, - "subject": "[Fwd: Map of Argentina with Description]", "to": { "Address": { "name": "White House Transportation Coordinator", @@ -88,10 +84,18 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz } }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "D7F------------D7FD5A0B8AB9C65CCDBFA872" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "D7F------------D7FD5A0B8AB9C65CCDBFA872" + } + } + }, + "from": { + "Address": { + "name": "Al Gore", + "address": "vice-president@whitehouse.gov" } } }, @@ -102,14 +106,18 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz ], "text_body": [ { - "header": { - "content_transfer_encoding": "7bit", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } + }, + "content_transfer_encoding": { + "Text": "7bit" } }, "contents": "Fred,\n\nFire up Air Force One! We're going South!\n\nThanks,\nAl" @@ -118,17 +126,44 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz "attachments": [ { "Message": { - "header": { + "headers": { + "mime_version": { + "Text": "1.0" + }, + "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 ;\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" + } + ] + }, + "message_id": { + "Text": "199804130742.RAA20366@mai1host.whitehouse.gov" + }, + "to": { + "Address": { + "name": "A1 Gore (The Enforcer)", + "address": "vice-president@whitehouse.gov" + } + }, + "subject": { + "Text": "Map of Argentina with Description" + }, "date": { - "year": 1998, - "month": 8, - "day": 13, - "hour": 17, - "minute": 42, - "second": 41, - "tz_before_gmt": false, - "tz_hour": 10, - "tz_minute": 0 + "DateTime": { + "year": 1998, + "month": 8, + "day": 13, + "hour": 17, + "minute": 42, + "second": 41, + "tz_before_gmt": false, + "tz_hour": 10, + "tz_minute": 0 + } }, "from": { "Address": { @@ -136,28 +171,17 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz "address": "president@whitehouse.gov" } }, - "message_id": "199804130742.RAA20366@mai1host.whitehouse.gov", - "mime_version": "1.0", - "received": [ - "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 ;\n Mon, 13 Aug 1998 l8:14:23 +1000", - "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": [ - "president@whitehouse.gov" - ], - "subject": "Map of Argentina with Description", - "to": { - "Address": { - "name": "A1 Gore (The Enforcer)", - "address": "vice-president@whitehouse.gov" + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "DC8------------DC8638F443D87A7F0726DEF7" + } } }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "DC8------------DC8638F443D87A7F0726DEF7" - } + "return_path": { + "Text": "president@whitehouse.gov" } }, "html_body": [ @@ -168,14 +192,18 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz ], "text_body": [ { - "header": { - "content_transfer_encoding": "7bit", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } + }, + "content_transfer_encoding": { + "Text": "7bit" } }, "contents": "Hi A1,\n\nI finally figured out this MIME thing. Pretty cool. I'll send you\nsome sax music in .au files next week!\n\nAnyway, the attached image is really too small to get a good look at\nArgentina. Try this for a much better map:\n\n http://www.1one1yp1anet.com/dest/sam/graphics/map-arg.htm\n\nThen again, shouldn't the CIA have something like that?\n\nBill" @@ -185,19 +213,25 @@ U6ZGxseyk8SasGw3J9GRzdTQky1iHNvcPNNI4TLeKdfMvy0vMqLrItvuxfDW8ubjueDtJufz "attachments": [ { "InlineBinary": { - "header": { - "content_disposition": { - "c_type": "inline", - "attributes": { - "fi1ename": "map_of_Argentina.gif" + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, + "content_type": { + "ContentType": { + "c_type": "image", + "c_subtype": "gif", + "attributes": { + "name": "map_of_Argentina.gif" + } } }, - "content_transfer_encoding": "base64", - "content_type": { - "c_type": "image", - "c_subtype": "gif", - "attributes": { - "name": "map_of_Argentina.gif" + "content_disposition": { + "ContentType": { + "c_type": "inline", + "attributes": { + "fi1ename": "map_of_Argentina.gif" + } } } }, diff --git a/tests/rfc/003.txt b/tests/rfc/003.txt index 3008b7e..e2d25b9 100644 --- a/tests/rfc/003.txt +++ b/tests/rfc/003.txt @@ -25,17 +25,27 @@ Content-Type: application/x-whatever ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 1993, - "month": 3, - "day": 22, - "hour": 9, - "minute": 41, - "second": 9, - "tz_before_gmt": true, - "tz_hour": 8, - "tz_minute": 0 + "headers": { + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "alternative", + "attributes": { + "boundary": "boundary42" + } + } + }, + "mime_version": { + "Text": "1.0" + }, + "subject": { + "Text": "Formatted text mail" + }, + "to": { + "Address": { + "name": "Ned Freed", + "address": "ned@innosoft.com" + } }, "from": { "Address": { @@ -43,19 +53,17 @@ Content-Type: application/x-whatever "address": "nsb@bellcore.com" } }, - "mime_version": "1.0", - "subject": "Formatted text mail", - "to": { - "Address": { - "name": "Ned Freed", - "address": "ned@innosoft.com" - } - }, - "content_type": { - "c_type": "multipart", - "c_subtype": "alternative", - "attributes": { - "boundary": "boundary42" + "date": { + "DateTime": { + "year": 1993, + "month": 3, + "day": 22, + "hour": 9, + "minute": 41, + "second": 9, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 } } }, @@ -66,12 +74,14 @@ Content-Type: application/x-whatever ], "text_body": [ { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } } }, @@ -81,10 +91,12 @@ Content-Type: application/x-whatever "attachments": [ { "Text": { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "enriched" + "ContentType": { + "c_type": "text", + "c_subtype": "enriched" + } } }, "contents": "... RFC 1896 text/enriched version of same message\n goes here ...\n" @@ -92,10 +104,12 @@ Content-Type: application/x-whatever }, { "Binary": { - "header": { + "headers": { "content_type": { - "c_type": "application", - "c_subtype": "x-whatever" + "ContentType": { + "c_type": "application", + "c_subtype": "x-whatever" + } } }, "contents": [ diff --git a/tests/rfc/004.txt b/tests/rfc/004.txt index fc6c19f..a5fac6c 100644 --- a/tests/rfc/004.txt +++ b/tests/rfc/004.txt @@ -36,35 +36,43 @@ Subject: my different opinion ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 1994, - "month": 3, - "day": 22, - "hour": 13, - "minute": 34, - "second": 51, - "tz_before_gmt": false, - "tz_hour": 0, - "tz_minute": 0 + "headers": { + "subject": { + "Text": "Internet Digest, volume 42" + }, + "mime_version": { + "Text": "1.0" + }, + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "---- main boundary ----" + } + } + }, + "to": { + "Address": { + "name": "Recipient-List" + } }, "from": { "Address": { "name": "Moderator-Address" } }, - "mime_version": "1.0", - "subject": "Internet Digest, volume 42", - "to": { - "Address": { - "name": "Recipient-List" - } - }, - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "---- main boundary ----" + "date": { + "DateTime": { + "year": 1994, + "month": 3, + "day": 22, + "hour": 13, + "minute": 34, + "second": 51, + "tz_before_gmt": false, + "tz_hour": 0, + "tz_minute": 0 } } }, @@ -81,24 +89,28 @@ Subject: my different opinion "attachments": [ { "Message": { - "header": { - "date": { - "year": 1993, - "month": 3, - "day": 26, - "hour": 11, - "minute": 13, - "second": 32, - "tz_before_gmt": false, - "tz_hour": 2, - "tz_minute": 0 - }, + "headers": { "from": { "Address": { "name": "someone-else" } }, - "subject": "my opinion" + "date": { + "DateTime": { + "year": 1993, + "month": 3, + "day": 26, + "hour": 11, + "minute": 13, + "second": 32, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } + }, + "subject": { + "Text": "my opinion" + } }, "html_body": [ { @@ -114,24 +126,28 @@ Subject: my different opinion }, { "Message": { - "header": { - "date": { - "year": 1993, - "month": 3, - "day": 26, - "hour": 10, - "minute": 7, - "second": 13, - "tz_before_gmt": true, - "tz_hour": 5, - "tz_minute": 0 - }, + "headers": { "from": { "Address": { "name": "someone-else-again" } }, - "subject": "my different opinion" + "date": { + "DateTime": { + "year": 1993, + "month": 3, + "day": 26, + "hour": 10, + "minute": 7, + "second": 13, + "tz_before_gmt": true, + "tz_hour": 5, + "tz_minute": 0 + } + }, + "subject": { + "Text": "my different opinion" + } }, "html_body": [ { diff --git a/tests/rfc/005.txt b/tests/rfc/005.txt index 57c95f8..20a8605 100644 --- a/tests/rfc/005.txt +++ b/tests/rfc/005.txt @@ -25,37 +25,45 @@ This is the epilogue. It is also to be ignored. ---- EXPECTED STRUCTURE ---- { - "header": { - "date": { - "year": 1993, - "month": 3, - "day": 21, - "hour": 23, - "minute": 56, - "second": 48, - "tz_before_gmt": true, - "tz_hour": 8, - "tz_minute": 0 - }, + "headers": { "from": { "Address": { "name": "Nathaniel Borenstein", "address": "nsb@bellcore.com" } }, - "mime_version": "1.0", - "subject": "Sample message", "to": { "Address": { "name": "Ned Freed", "address": "ned@innosoft.com" } }, + "subject": { + "Text": "Sample message" + }, + "mime_version": { + "Text": "1.0" + }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "simple boundary" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "simple boundary" + } + } + }, + "date": { + "DateTime": { + "year": 1993, + "month": 3, + "day": 21, + "hour": 23, + "minute": 56, + "second": 48, + "tz_before_gmt": true, + "tz_hour": 8, + "tz_minute": 0 } } }, @@ -72,12 +80,14 @@ This is the epilogue. It is also to be ignored. "contents": "This is implicitly typed plain US-ASCII text.\nIt does NOT end with a linebreak." }, { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } } }, diff --git a/tests/rfc/006.txt b/tests/rfc/006.txt index 4956f16..3dbe713 100644 --- a/tests/rfc/006.txt +++ b/tests/rfc/006.txt @@ -23,39 +23,49 @@ Content-Disposition: inline ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "from": { "Address": { "address": "sender@example.com" } }, - "subject": "Multipart Email Example", + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "alternative", + "attributes": { + "boundary": "boundary-string" + } + } + }, "to": { "Address": { "address": "recipient@example.com" } }, - "content_type": { - "c_type": "multipart", - "c_subtype": "alternative", - "attributes": { - "boundary": "boundary-string" - } + "subject": { + "Text": "Multipart Email Example" } }, "html_body": [ { - "header": { - "content_disposition": { - "c_type": "inline" - }, - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "utf-8" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "utf-8" + } } + }, + "content_disposition": { + "ContentType": { + "c_type": "inline" + } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "

This is the HTML Section!

\n

This is what displays in most modern email clients

\n" @@ -63,16 +73,22 @@ Content-Disposition: inline ], "text_body": [ { - "header": { + "headers": { + "content_transfer_encoding": { + "Text": "quoted-printable" + }, "content_disposition": { - "c_type": "inline" + "ContentType": { + "c_type": "inline" + } }, - "content_transfer_encoding": "quoted-printable", "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "utf-8" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "utf-8" + } } } }, diff --git a/tests/rfc/007.txt b/tests/rfc/007.txt index 9992369..773868c 100644 --- a/tests/rfc/007.txt +++ b/tests/rfc/007.txt @@ -73,13 +73,17 @@ K ---- EXPECTED STRUCTURE ---- { - "header": { - "subject": "RFC 8621 Section 4.1.4 test", + "headers": { + "subject": { + "Text": "RFC 8621 Section 4.1.4 test" + }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "1" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "1" + } } } }, @@ -88,10 +92,12 @@ K "contents": "A" }, { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "html" + "ContentType": { + "c_type": "text", + "c_subtype": "html" + } } }, "contents": "E" @@ -102,50 +108,66 @@ K ], "text_body": [ { - "header": { + "headers": { "content_disposition": { - "c_type": "inline" + "ContentType": { + "c_type": "inline" + } }, "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "A" }, { - "header": { - "content_disposition": { - "c_type": "inline" - }, + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } + }, + "content_disposition": { + "ContentType": { + "c_type": "inline" + } } }, "contents": "B" }, 0, { - "header": { + "headers": { "content_disposition": { - "c_type": "inline" + "ContentType": { + "c_type": "inline" + } }, "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "D" }, { - "header": { - "content_disposition": { - "c_type": "inline" - }, + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } + }, + "content_disposition": { + "ContentType": { + "c_type": "inline" + } } }, "contents": "K" @@ -154,13 +176,17 @@ K "attachments": [ { "InlineBinary": { - "header": { - "content_disposition": { - "c_type": "inline" - }, + "headers": { "content_type": { - "c_type": "image", - "c_subtype": "jpeg" + "ContentType": { + "c_type": "image", + "c_subtype": "jpeg" + } + }, + "content_disposition": { + "ContentType": { + "c_type": "inline" + } } }, "contents": [ @@ -170,10 +196,12 @@ K }, { "Binary": { - "header": { + "headers": { "content_type": { - "c_type": "image", - "c_subtype": "jpeg" + "ContentType": { + "c_type": "image", + "c_subtype": "jpeg" + } } }, "contents": [ @@ -183,13 +211,17 @@ K }, { "Binary": { - "header": { - "content_disposition": { - "c_type": "attachment" - }, + "headers": { "content_type": { - "c_type": "image", - "c_subtype": "jpeg" + "ContentType": { + "c_type": "image", + "c_subtype": "jpeg" + } + }, + "content_disposition": { + "ContentType": { + "c_type": "attachment" + } } }, "contents": [ @@ -199,10 +231,12 @@ K }, { "Binary": { - "header": { + "headers": { "content_type": { - "c_type": "application", - "c_subtype": "x-excel" + "ContentType": { + "c_type": "application", + "c_subtype": "x-excel" + } } }, "contents": [ @@ -212,8 +246,10 @@ K }, { "Message": { - "header": { - "subject": "J" + "headers": { + "subject": { + "Text": "J" + } }, "html_body": [ { diff --git a/tests/thirdparty/000.txt b/tests/thirdparty/000.txt index 40ff327..d7e03fd 100644 --- a/tests/thirdparty/000.txt +++ b/tests/thirdparty/000.txt @@ -20,14 +20,18 @@ ZWg= ---- EXPECTED STRUCTURE ---- { - "header": { - "mime_version": "1.0", + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "alternative", - "attributes": { - "boundary": "bound" + "ContentType": { + "c_type": "multipart", + "c_subtype": "alternative", + "attributes": { + "boundary": "bound" + } } + }, + "mime_version": { + "Text": "1.0" } }, "html_body": [ @@ -40,21 +44,29 @@ ZWg= ], "text_body": [ { - "header": { - "content_transfer_encoding": "base64", + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "we have\ra lot \nof \u0000binary stuff in here\nb adjig sadjg jasidgjiaehga3wht8a3w8ghxjc dsgad hasdghsd gasd dsjdsoga sjdga0w3tjhawjgsertniq3n5oqerjqw2r89q23h awhrqh835r8a" }, { - "header": { - "content_transfer_encoding": "base64", + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "eh" diff --git a/tests/thirdparty/001.txt b/tests/thirdparty/001.txt index 7fd1b95..aeb58db 100644 --- a/tests/thirdparty/001.txt +++ b/tests/thirdparty/001.txt @@ -25,14 +25,18 @@ hello world ---- EXPECTED STRUCTURE ---- { - "header": { - "mime_version": "1.0", + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "alternative", - "attributes": { - "boundary": "bound" + "ContentType": { + "c_type": "multipart", + "c_subtype": "alternative", + "attributes": { + "boundary": "bound" + } } + }, + "mime_version": { + "Text": "1.0" } }, "html_body": [ @@ -48,30 +52,40 @@ hello world ], "text_body": [ { - "header": { - "content_transfer_encoding": "binary", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } + }, + "content_transfer_encoding": { + "Text": "binary" } }, "contents": "d2UgaGF2ZQ1hIGxvdCAKb2YgAGJpbmFyeSBzdHVmZiBpbiBoZXJlCmIgYWRqaWcgc2FkamcgamFz\r\naWRnamlhZWhnYTN3aHQ4YTN3OGdoeGpjIGRzZ2FkIGhhc2RnaHNkIGdhc2QgZHNqZHNvZ2Egc2pk\r\nZ2EwdzN0amhhd2pnc2VydG5pcTNuNW9xZXJqcXcycjg5cTIzaCBhd2hycWg4MzVyOGE=\r" }, { - "header": { - "content_transfer_encoding": "binary", + "headers": { + "content_transfer_encoding": { + "Text": "binary" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "ZWg=" }, { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "hello world\r\n\r" diff --git a/tests/thirdparty/002.txt b/tests/thirdparty/002.txt index 18a66da..446f81b 100644 --- a/tests/thirdparty/002.txt +++ b/tests/thirdparty/002.txt @@ -20,12 +20,14 @@ Content-Type: text/plain; charset=utf-8 ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "foo" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "foo" + } } } }, @@ -39,26 +41,34 @@ Content-Type: text/plain; charset=utf-8 ], "text_body": [ { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "utf-8" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "utf-8" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "päivää\n" }, { - "header": { - "content_transfer_encoding": "base64", + "headers": { + "content_transfer_encoding": { + "Text": "base64" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "utf-8" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "utf-8" + } } } }, @@ -68,14 +78,18 @@ Content-Type: text/plain; charset=utf-8 "attachments": [ { "Text": { - "header": { - "content_transfer_encoding": "base64", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "utf-8" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "utf-8" + } } + }, + "content_transfer_encoding": { + "Text": "base64" } }, "contents": "?garbage" diff --git a/tests/thirdparty/003.txt b/tests/thirdparty/003.txt index 6d210c0..3faab26 100644 --- a/tests/thirdparty/003.txt +++ b/tests/thirdparty/003.txt @@ -35,14 +35,18 @@ TW92ZSDimZogdG8g4pmbJ3Mg4pmdCg== ---- EXPECTED STRUCTURE ---- { - "header": { - "mime_version": "1.0", + "headers": { "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "1" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "1" + } } + }, + "mime_version": { + "Text": "1.0" } }, "html_body": [ @@ -64,66 +68,86 @@ TW92ZSDimZogdG8g4pmbJ3Mg4pmdCg== ], "text_body": [ { - "header": { - "content_transfer_encoding": "7bit", + "headers": { + "content_transfer_encoding": { + "Text": "7bit" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } } }, "contents": "Move black king to queen's bishop\n" }, { - "header": { - "content_transfer_encoding": "binary", + "headers": { + "content_transfer_encoding": { + "Text": "binary" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "UTF-8" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "UTF-8" + } } } }, "contents": "Move ♚ to ♛'s ♝\n" }, { - "header": { - "content_transfer_encoding": "8bit", + "headers": { + "content_transfer_encoding": { + "Text": "8bit" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "UTF-8" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "UTF-8" + } } } }, "contents": "Move ♚ to ♛'s ♝\n" }, { - "header": { - "content_transfer_encoding": "quoted-printable", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "UTF-8" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "UTF-8" + } } + }, + "content_transfer_encoding": { + "Text": "quoted-printable" } }, "contents": "Move ♚ to ♛'s ♝\n" }, { - "header": { - "content_transfer_encoding": "base64", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "UTF-8" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "UTF-8" + } } + }, + "content_transfer_encoding": { + "Text": "base64" } }, "contents": "Move ♚ to ♛'s ♝\n" diff --git a/tests/thirdparty/004.txt b/tests/thirdparty/004.txt index adadd22..64e51bb 100644 --- a/tests/thirdparty/004.txt +++ b/tests/thirdparty/004.txt @@ -41,13 +41,17 @@ Move =E2=99=9A to =E2=99=9B's =E2=99=9D ---- EXPECTED STRUCTURE ---- { - "header": { - "mime_version": "1.0", + "headers": { + "mime_version": { + "Text": "1.0" + }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "1" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "1" + } } } }, @@ -73,77 +77,99 @@ Move =E2=99=9A to =E2=99=9B's =E2=99=9D ], "text_body": [ { - "header": { - "content_transfer_encoding": "6bit", + "headers": { + "content_transfer_encoding": { + "Text": "6bit" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "UTF-8" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "UTF-8" + } } } }, "contents": "Move black king to queen's bishop\n" }, { - "header": { - "content_transfer_encoding": "7bits", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "UTF-8" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "UTF-8" + } + } + }, + "content_transfer_encoding": { + "Text": "7bits" + } + }, + "contents": "Move ♚ to ♛'s ♝\n" + }, + { + "headers": { + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "UTF-8" + } + } + }, + "content_transfer_encoding": { + "Text": "8 bit" + } + }, + "contents": "Move ♚ to ♛'s ♝\n" + }, + { + "headers": { + "content_transfer_encoding": { + "Text": "7-bit" + }, + "content_type": { + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "UTF-8" + } } } }, "contents": "Move ♚ to ♛'s ♝\n" }, { - "header": { - "content_transfer_encoding": "8 bit", + "headers": { + "content_transfer_encoding": { + "Text": "8-bit" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "UTF-8" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "UTF-8" + } } } }, "contents": "Move ♚ to ♛'s ♝\n" }, { - "header": { - "content_transfer_encoding": "7-bit", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "UTF-8" - } - } - }, - "contents": "Move ♚ to ♛'s ♝\n" - }, - { - "header": { - "content_transfer_encoding": "8-bit", - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "UTF-8" - } - } - }, - "contents": "Move ♚ to ♛'s ♝\n" - }, - { - "header": { - "content_type": { - "c_type": "text", - "c_subtype": "plain", - "attributes": { - "charset": "UTF-8" + "ContentType": { + "c_type": "text", + "c_subtype": "plain", + "attributes": { + "charset": "UTF-8" + } } } }, diff --git a/tests/thirdparty/005.txt b/tests/thirdparty/005.txt index 4fb906e..10fdc49 100644 Binary files a/tests/thirdparty/005.txt and b/tests/thirdparty/005.txt differ diff --git a/tests/thirdparty/006.txt b/tests/thirdparty/006.txt index 984d269..b1e3ff3 100644 --- a/tests/thirdparty/006.txt +++ b/tests/thirdparty/006.txt @@ -30,25 +30,33 @@ Signed by undersigned --1-- ---- EXPECTED STRUCTURE ---- { - "header": { - "mime_version": "1.0", - "subject": "Hide and seek", + "headers": { + "mime_version": { + "Text": "1.0" + }, + "subject": { + "Text": "Hide and seek" + }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "1" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "1" + } } } }, "html_body": [ { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "html", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "html", + "attributes": { + "charset": "us-ascii" + } } } }, @@ -57,11 +65,15 @@ Signed by undersigned ], "text_body": [ { - "header": { - "content_transfer_encoding": "binary", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } + }, + "content_transfer_encoding": { + "Text": "binary" } }, "contents": "Search me, and Find me here" @@ -70,12 +82,14 @@ Signed by undersigned "attachments": [ { "Binary": { - "header": { + "headers": { "content_type": { - "c_type": "signature", - "c_subtype": "plain", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "signature", + "c_subtype": "plain", + "attributes": { + "charset": "us-ascii" + } } } }, diff --git a/tests/thirdparty/007.txt b/tests/thirdparty/007.txt index 7fce7f7..2db7acc 100644 --- a/tests/thirdparty/007.txt +++ b/tests/thirdparty/007.txt @@ -34,7 +34,7 @@ Foobar --1-- ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { "from": { "Address": { "name": "Moderator-Address", @@ -42,24 +42,28 @@ Foobar } }, "content_type": { - "c_type": "multipart", - "c_subtype": "digest", - "attributes": { - "boundary": "1" + "ContentType": { + "c_type": "multipart", + "c_subtype": "digest", + "attributes": { + "boundary": "1" + } } } }, "attachments": [ { "Message": { - "header": { + "headers": { + "subject": { + "Text": "my opinion" + }, "from": { "Address": { "name": "someone-else", "address": "someone@else" } - }, - "subject": "my opinion" + } }, "html_body": [ { @@ -75,14 +79,16 @@ Foobar }, { "Message": { - "header": { + "headers": { + "subject": { + "Text": "i disagree" + }, "from": { "Address": { "name": "another one", "address": "another@one" } - }, - "subject": "i disagree" + } }, "html_body": [ { @@ -98,19 +104,23 @@ Foobar }, { "Message": { - "header": { + "headers": { + "subject": { + "Text": "funny hat" + }, "from": { "Address": { "name": "attachment", "address": "attachment@user" } }, - "subject": "funny hat", "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "2" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "2" + } } } }, @@ -121,11 +131,15 @@ Foobar ], "text_body": [ { - "header": { - "content_transfer_encoding": "binary", + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } + }, + "content_transfer_encoding": { + "Text": "binary" } }, "contents": "Lovely attachment for you" @@ -134,14 +148,18 @@ Foobar "attachments": [ { "Binary": { - "header": { - "content_transfer_encoding": "binary", + "headers": { + "content_transfer_encoding": { + "Text": "binary" + }, "content_type": { - "c_type": "application", - "c_subtype": "octet-stream", - "attributes": { - "name": "test.txt", - "disposition": "attachment" + "ContentType": { + "c_type": "application", + "c_subtype": "octet-stream", + "attributes": { + "name": "test.txt", + "disposition": "attachment" + } } } }, diff --git a/tests/thirdparty/008.txt b/tests/thirdparty/008.txt index 5355085..1a6965a 100644 --- a/tests/thirdparty/008.txt +++ b/tests/thirdparty/008.txt @@ -57,35 +57,36 @@ Root MIME epilogue ---- EXPECTED STRUCTURE ---- { - "header": { + "headers": { + "content_type": { + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "foo bar" + } + } + }, "date": { - "year": 2007, - "month": 3, - "day": 24, - "hour": 23, - "minute": 0, - "second": 0, - "tz_before_gmt": false, - "tz_hour": 2, - "tz_minute": 0 + "DateTime": { + "year": 2007, + "month": 3, + "day": 24, + "hour": 23, + "minute": 0, + "second": 0, + "tz_before_gmt": false, + "tz_hour": 2, + "tz_minute": 0 + } }, "from": { "Address": { "address": "user@domain.org" } }, - "mime_version": "1.0", - "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "foo bar" - } - }, - "others": { - "From user@domain Fri Feb 22 17": [ - "06:23 2008" - ] + "mime_version": { + "Text": "1.0" } }, "html_body": [ @@ -95,10 +96,12 @@ Root MIME epilogue ], "text_body": [ { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "Another part" @@ -107,12 +110,14 @@ Root MIME epilogue "attachments": [ { "Text": { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "x-myown", - "attributes": { - "charset": "us-ascii" + "ContentType": { + "c_type": "text", + "c_subtype": "x-myown", + "attributes": { + "charset": "us-ascii" + } } } }, @@ -121,38 +126,46 @@ Root MIME epilogue }, { "Message": { - "header": { - "date": { - "year": 2012, - "month": 8, - "day": 12, - "hour": 12, - "minute": 34, - "second": 56, - "tz_before_gmt": false, - "tz_hour": 3, - "tz_minute": 0 - }, + "headers": { "from": { "Address": { "address": "sub@domain.org" } }, - "subject": "submsg", + "subject": { + "Text": "submsg" + }, + "date": { + "DateTime": { + "year": 2012, + "month": 8, + "day": 12, + "hour": 12, + "minute": 34, + "second": 56, + "tz_before_gmt": false, + "tz_hour": 3, + "tz_minute": 0 + } + }, "content_type": { - "c_type": "multipart", - "c_subtype": "alternative", - "attributes": { - "boundary": "sub1" + "ContentType": { + "c_type": "multipart", + "c_subtype": "alternative", + "attributes": { + "boundary": "sub1" + } } } }, "html_body": [ { - "header": { + "headers": { "content_type": { - "c_type": "text", - "c_subtype": "html" + "ContentType": { + "c_type": "text", + "c_subtype": "html" + } } }, "contents": "

Hello world

\n" diff --git a/tests/thirdparty/009.txt b/tests/thirdparty/009.txt index 2570882..ad38c07 100644 --- a/tests/thirdparty/009.txt +++ b/tests/thirdparty/009.txt @@ -21,14 +21,20 @@ dGhpcyBpcyB0aGUgZmlyc3QgcGFydCBvZiB0aGUgbWVzc2FnZQo= ---- EXPECTED STRUCTURE ---- { - "header": { - "mime_version": "1.0", - "subject": "In parts", + "headers": { + "subject": { + "Text": "In parts" + }, + "mime_version": { + "Text": "1.0" + }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "boundary": "1" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "boundary": "1" + } } } }, @@ -39,11 +45,15 @@ dGhpcyBpcyB0aGUgZmlyc3QgcGFydCBvZiB0aGUgbWVzc2FnZQo= ], "text_body": [ { - "header": { - "content_transfer_encoding": "binary", + "headers": { + "content_transfer_encoding": { + "Text": "binary" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } } }, "contents": "Hi, this is the fancy thing I was talking about!" @@ -52,14 +62,16 @@ dGhpcyBpcyB0aGUgZmlyc3QgcGFydCBvZiB0aGUgbWVzc2FnZQo= "attachments": [ { "Binary": { - "header": { + "headers": { "content_type": { - "c_type": "message", - "c_subtype": "partial", - "attributes": { - "total": "5", - "number": "1", - "id": "heks68ewe@example.org" + "ContentType": { + "c_type": "message", + "c_subtype": "partial", + "attributes": { + "total": "5", + "number": "1", + "id": "heks68ewe@example.org" + } } } }, diff --git a/tests/thirdparty/010.txt b/tests/thirdparty/010.txt index 65df86d..2422da3 100644 --- a/tests/thirdparty/010.txt +++ b/tests/thirdparty/010.txt @@ -12,15 +12,21 @@ Content-Language: ja --1-- ---- EXPECTED STRUCTURE ---- { - "header": { - "mime_version": "1.0", - "subject": "こんにちは", + "headers": { + "subject": { + "Text": "こんにちは" + }, + "mime_version": { + "Text": "1.0" + }, "content_type": { - "c_type": "multipart", - "c_subtype": "mixed", - "attributes": { - "comment": "人権の無視及", - "boundary": "1" + "ContentType": { + "c_type": "multipart", + "c_subtype": "mixed", + "attributes": { + "comment": "人権の無視及", + "boundary": "1" + } } } }, @@ -31,11 +37,18 @@ Content-Language: ja ], "text_body": [ { - "header": { - "content_transfer_encoding": "binary", + "headers": { + "content_transfer_encoding": { + "Text": "binary" + }, "content_type": { - "c_type": "text", - "c_subtype": "plain" + "ContentType": { + "c_type": "text", + "c_subtype": "plain" + } + }, + "content_language": { + "Text": "ja" } }, "contents": "人権の無視及"