summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hurst <tom@hur.st>2018-09-07 02:07:09 +0100
committerKartikaya Gupta (kats) <staktrace@users.noreply.github.com>2018-09-07 11:51:51 -0400
commitd535c57ad328e6ed2f4d000ac88c2bcc5e2fdc35 (patch)
treea52519e3c436f3d566f84f906899f3dd3b0cdcea
parent9dbcb303d6533a89b4edff14eacfdb0526444008 (diff)
downloadmailparse-d535c57ad328e6ed2f4d000ac88c2bcc5e2fdc35.tar.gz
mailparse-d535c57ad328e6ed2f4d000ac88c2bcc5e2fdc35.tar.xz
Tidy get_body_raw() with is_ascii_whitespace()
Semantics aren't *identical*, since this adds vertical tab to the filter.
-rw-r--r--src/lib.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 6a70a69..ad8daae 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -682,12 +682,11 @@ impl<'a> ParsedMail<'a> {
.map(|s| s.to_lowercase());
let decoded = match transfer_coding.unwrap_or_default().as_ref() {
"base64" => {
- let cleaned = self.body
+ let cleaned = self
+ .body
.iter()
- .filter_map(|&c| match c {
- b' ' | b'\t' | b'\r' | b'\n' => None,
- v => Some(v),
- })
+ .filter(|c| !c.is_ascii_whitespace())
+ .cloned()
.collect::<Vec<u8>>();
base64::decode(&cleaned)?
}