summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib.rs b/src/lib.rs
index ad8daae..e7a74a9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -678,10 +678,13 @@ impl<'a> ParsedMail<'a> {
/// assert_eq!(p.get_body_raw().unwrap(), b"This is the body");
/// ```
pub fn get_body_raw(&self) -> Result<Vec<u8>, MailParseError> {
- let transfer_coding = self.headers.get_first_value("Content-Transfer-Encoding")?
+ let transfer_coding = self
+ .headers
+ .get_first_value("Content-Transfer-Encoding")?
.map(|s| s.to_lowercase());
- let decoded = match transfer_coding.unwrap_or_default().as_ref() {
- "base64" => {
+
+ let decoded = match transfer_coding {
+ Some(ref enc) if enc == "base64" => {
let cleaned = self
.body
.iter()
@@ -690,11 +693,8 @@ impl<'a> ParsedMail<'a> {
.collect::<Vec<u8>>();
base64::decode(&cleaned)?
}
- "quoted-printable" => {
- quoted_printable::decode(
- self.body,
- quoted_printable::ParseMode::Robust,
- )?
+ Some(ref enc) if enc == "quoted-printable" => {
+ quoted_printable::decode(self.body, quoted_printable::ParseMode::Robust)?
}
_ => Vec::<u8>::from(self.body),
};