diff --git a/Cargo.toml b/Cargo.toml index a66cddb..2d27f12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ exclude = [".gitattributes", ".gitignore", ".github/**", "examples/**"] maintenance = { status = "passively-maintained" } [dependencies] -data-encoding = "2.3.3" +data-encoding = "2.6.0" quoted_printable = "0.5.0" charset = "0.1.3" diff --git a/src/body.rs b/src/body.rs index fd60c04..b70e95b 100644 --- a/src/body.rs +++ b/src/body.rs @@ -1,6 +1,7 @@ -use crate::{MailParseError, ParsedContentType}; use charset::{decode_ascii, Charset}; +use crate::{MailParseError, ParsedContentType}; + /// Represents the body of an email (or mail subpart) pub enum Body<'a> { /// A body with 'base64' Content-Transfer-Encoding. @@ -141,7 +142,7 @@ fn decode_base64(body: &[u8]) -> Result, MailParseError> { .filter(|c| !c.is_ascii_whitespace()) .cloned() .collect::>(); - Ok(data_encoding::BASE64_MIME.decode(&cleaned)?) + Ok(data_encoding::BASE64_MIME_PERMISSIVE.decode(&cleaned)?) } fn decode_quoted_printable(body: &[u8]) -> Result, MailParseError> { diff --git a/src/header.rs b/src/header.rs index a8c2301..b3e4c32 100644 --- a/src/header.rs +++ b/src/header.rs @@ -45,7 +45,9 @@ fn decode_word(encoded: &str) -> Option { let input = &encoded[ix_delim2 + 1..]; let decoded = match transfer_coding { - "B" | "b" => data_encoding::BASE64_MIME.decode(input.as_bytes()).ok()?, + "B" | "b" => data_encoding::BASE64_MIME_PERMISSIVE + .decode(input.as_bytes()) + .ok()?, "Q" | "q" => { // The quoted_printable module does a trim_end on the input, so if // that affects the output we should save and restore the trailing