Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use BASE64_MIME_PERMISSIVE to allow trailing bits in b64 data #126

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
5 changes: 3 additions & 2 deletions src/body.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -141,7 +142,7 @@ fn decode_base64(body: &[u8]) -> Result<Vec<u8>, MailParseError> {
.filter(|c| !c.is_ascii_whitespace())
.cloned()
.collect::<Vec<u8>>();
Ok(data_encoding::BASE64_MIME.decode(&cleaned)?)
Ok(data_encoding::BASE64_MIME_PERMISSIVE.decode(&cleaned)?)
}

fn decode_quoted_printable(body: &[u8]) -> Result<Vec<u8>, MailParseError> {
Expand Down
4 changes: 3 additions & 1 deletion src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ fn decode_word(encoded: &str) -> Option<String> {
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
Expand Down
Loading