mirror of
https://github.com/stalwartlabs/mail-parser.git
synced 2026-11-29 00:01:49 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf8de086c7 | ||
|
|
c7ae90b3bf |
@@ -1,3 +1,7 @@
|
||||
mail-parser 0.8.1
|
||||
================================
|
||||
- Added `raw_message()` function.
|
||||
|
||||
mail-parser 0.8.0
|
||||
================================
|
||||
- Removed get_() prefixes (#31).
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "mail-parser"
|
||||
description = "Fast and robust e-mail parsing library for Rust"
|
||||
version = "0.8.0"
|
||||
version = "0.8.1"
|
||||
edition = "2018"
|
||||
authors = [ "Stalwart Labs <hello@stalw.art>"]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
|
||||
@@ -325,8 +325,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
super::base64_decode(encoded_str.as_bytes()).unwrap_or_default(),
|
||||
expected_result.as_bytes(),
|
||||
"Failed for {:?}",
|
||||
encoded_str
|
||||
"Failed for {encoded_str:?}",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -357,8 +356,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
result,
|
||||
expected_result.as_bytes(),
|
||||
"Failed for {:?}",
|
||||
encoded_str
|
||||
"Failed for {encoded_str:?}",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -376,8 +374,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
s.decode_base64_word().unwrap(),
|
||||
expected_result.as_bytes(),
|
||||
"Failed for {:?}",
|
||||
encoded_str
|
||||
"Failed for {encoded_str:?}",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ mod tests {
|
||||
use super::charset_decoder;
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::uninlined_format_args)]
|
||||
fn decoder_charset() {
|
||||
let inputs = [
|
||||
"l8",
|
||||
@@ -100,7 +101,7 @@ mod tests {
|
||||
for input in inputs {
|
||||
assert!(
|
||||
charset_decoder(input.as_bytes()).is_some(),
|
||||
"Failed for '{}'",
|
||||
"Failed for {}",
|
||||
input
|
||||
);
|
||||
}
|
||||
|
||||
@@ -331,8 +331,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
super::quoted_printable_decode(encoded_str.as_bytes()).unwrap_or_default(),
|
||||
expected_result.as_bytes(),
|
||||
"Failed for {:?}",
|
||||
encoded_str
|
||||
"Failed for {encoded_str:?}",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -394,8 +393,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
result,
|
||||
expected_result.as_bytes(),
|
||||
"Failed for {:?}",
|
||||
encoded_str
|
||||
"Failed for {encoded_str:?}",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -423,8 +421,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
s.decode_quoted_printable_word().unwrap_or_default(),
|
||||
expected_result.as_bytes(),
|
||||
"Failed for {:?}",
|
||||
encoded_str
|
||||
"Failed for {encoded_str:?}",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -983,6 +983,14 @@ impl<'x> Message<'x> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the raw message
|
||||
pub fn raw_message(&self) -> &[u8] {
|
||||
let part = &self.parts[0];
|
||||
self.raw_message
|
||||
.get(part.offset_header..part.offset_end)
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Returns the BCC header field
|
||||
pub fn bcc(&self) -> &HeaderValue {
|
||||
self.parts[0]
|
||||
|
||||
@@ -243,7 +243,7 @@ impl<'x> ContentTypeParser<'x> {
|
||||
for (key, _, value) in continuations.drain(..) {
|
||||
if let Some((_, old_value)) = self.attributes.iter_mut().find(|(name, _)| name == &key)
|
||||
{
|
||||
*old_value = format!("{}{}", old_value, value).into();
|
||||
*old_value = format!("{old_value}{value}").into();
|
||||
} else {
|
||||
self.attributes.push((key, value));
|
||||
}
|
||||
|
||||
@@ -423,7 +423,7 @@ impl<'x> MessageStream<'x> {
|
||||
parts[2]
|
||||
} as u16,
|
||||
month: if month_pos == 3 && month_hash <= 30 {
|
||||
MONTH_MAP[month_hash] as u8
|
||||
MONTH_MAP[month_hash]
|
||||
} else {
|
||||
parts[1] as u8
|
||||
},
|
||||
|
||||
@@ -275,7 +275,7 @@ mod tests {
|
||||
];
|
||||
|
||||
for (input, expected) in tests {
|
||||
assert_eq!(thread_name(input), expected, "{:?}", input);
|
||||
assert_eq!(thread_name(input), expected, "{input:?}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ mod tests {
|
||||
];
|
||||
|
||||
for (input, expected) in tests {
|
||||
assert_eq!(trim_trailing_fwd(input), expected, "{:?}", input);
|
||||
assert_eq!(trim_trailing_fwd(input), expected, "{input:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,8 +195,7 @@ mod tests {
|
||||
.parse_unstructured()
|
||||
.unwrap_text(),
|
||||
expected_result,
|
||||
"Failed to parse '{:?}'",
|
||||
input
|
||||
"Failed to parse '{input:?}'",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,8 +254,7 @@ mod tests {
|
||||
MessageStream::new(input.as_bytes())
|
||||
.parse_header_name()
|
||||
.unwrap(),
|
||||
"Failed to parse '{:?}'",
|
||||
input
|
||||
"Failed to parse '{input:?}'",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ use std::borrow::Cow;
|
||||
|
||||
use crate::decoders::html::html_to_text;
|
||||
|
||||
pub fn preview_html<'x, 'y>(html: Cow<'y, str>, max_len: usize) -> Cow<'x, str> {
|
||||
pub fn preview_html<'x>(html: Cow<'_, str>, max_len: usize) -> Cow<'x, str> {
|
||||
preview_text(html_to_text(html.as_ref()).into(), max_len)
|
||||
}
|
||||
|
||||
pub fn preview_text<'x, 'y>(text: Cow<'y, str>, mut max_len: usize) -> Cow<'x, str> {
|
||||
pub fn preview_text<'x>(text: Cow<'_, str>, mut max_len: usize) -> Cow<'x, str> {
|
||||
if text.len() > max_len {
|
||||
let add_dots = max_len > 6;
|
||||
if add_dots {
|
||||
@@ -39,11 +39,11 @@ pub fn preview_text<'x, 'y>(text: Cow<'y, str>, mut max_len: usize) -> Cow<'x, s
|
||||
}
|
||||
}
|
||||
|
||||
pub fn truncate_text<'x, 'y>(text: Cow<'y, str>, max_len: usize) -> Cow<'x, str> {
|
||||
pub fn truncate_text<'x>(text: Cow<'_, str>, max_len: usize) -> Cow<'x, str> {
|
||||
preview_text(text, max_len)
|
||||
}
|
||||
|
||||
pub fn truncate_html<'x, 'y>(html: Cow<'y, str>, mut max_len: usize) -> Cow<'x, str> {
|
||||
pub fn truncate_html<'x>(html: Cow<'_, str>, mut max_len: usize) -> Cow<'x, str> {
|
||||
if html.len() > max_len {
|
||||
let add_dots = max_len > 6;
|
||||
if add_dots {
|
||||
|
||||
Reference in New Issue
Block a user