Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sftse committed Dec 6, 2023
1 parent e0030a2 commit 7821347
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
41 changes: 21 additions & 20 deletions src/decoders/quoted_printable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,27 @@ impl<'x> MessageStream<'x> {
None
}
}

/*
* Adapted from Daniel Lemire's source:
* https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/2019/04/17/hexparse.cpp
*
*/

pub static HEX_MAP: &[i8] = &[
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10,
11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
];

#[cfg(test)]
mod tests {
use crate::parsers::MessageStream;
Expand Down Expand Up @@ -468,23 +489,3 @@ mod tests {
}
}
}

/*
* Adapted from Daniel Lemire's source:
* https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/2019/04/17/hexparse.cpp
*
*/

pub static HEX_MAP: &[i8] = &[
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10,
11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
];
10 changes: 4 additions & 6 deletions src/parsers/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ impl MessageParser {
message.text_body.push(message.parts.len());
}

if !is_multipart && !(add_to_text || add_to_html)
if !is_multipart && !add_to_text && !add_to_html
|| (is_media || is_multipart) && (!add_to_text || !add_to_html)
{
message.attachments.push(message.parts.len());
Expand Down Expand Up @@ -343,12 +343,10 @@ impl MessageParser {
} else {
PartType::Text(text)
}
} else if !is_inline {
PartType::Binary(bytes)
} else {
if !is_inline {
PartType::Binary(bytes)
} else {
PartType::InlineBinary(bytes)
}
PartType::InlineBinary(bytes)
}
} else {
message.attachments.push(message.parts.len());
Expand Down
8 changes: 4 additions & 4 deletions src/parsers/mime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ impl<'x> MessageStream<'x> {
self.checkpoint();

match (self.next(), self.peek()) {
(Some(&a), Some(&&b)) if a == b'\r' && b == b'\n' => {
(Some(b'\r'), Some(b'\n')) => {
self.next();
false
}
(Some(&a), Some(&&b)) if a == b'-' && b == b'-' => {
(Some(b'-'), Some(b'-')) => {
self.next();
true
}
(Some(&a), _) if a == b'\n' => false,
(Some(&a), _) if a.is_ascii_whitespace() => {
(Some(b'\n'), _) => false,
(Some(a), _) if a.is_ascii_whitespace() => {
self.skip_crlf();
false
}
Expand Down

0 comments on commit 7821347

Please sign in to comment.