mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 09:56:35 +03:00
Update rust-email, test that no empty lines are produced (#2119)
* Add a failing test for #2118 * Update rust-email to fix #2118
This commit is contained in:
@@ -1618,4 +1618,56 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_no_empty_lines_in_header() {
|
||||
// See https://github.com/deltachat/deltachat-core-rust/issues/2118
|
||||
let to_tuples = [
|
||||
("Nnnn", "nnn@ttttttttt.de"),
|
||||
("😀 ttttttt", "ttttttt@rrrrrr.net"),
|
||||
("dididididididi", "t@iiiiiii.org"),
|
||||
("Ttttttt", "oooooooooo@abcd.de"),
|
||||
("Mmmmm", "mmmmm@rrrrrr.net"),
|
||||
("Zzzzzz", "rrrrrrrrrrrrr@ttttttttt.net"),
|
||||
("Xyz", "qqqqqqqqqq@rrrrrr.net"),
|
||||
("", "geug@ttttttttt.de"),
|
||||
("qqqqqq", "q@iiiiiii.org"),
|
||||
("bbbb", "bbbb@iiiiiii.org"),
|
||||
("", "fsfs@iiiiiii.org"),
|
||||
("rqrqrqrqr", "rqrqr@iiiiiii.org"),
|
||||
("tttttttt", "tttttttt@iiiiiii.org"),
|
||||
("", "tttttt@rrrrrr.net"),
|
||||
]
|
||||
.iter();
|
||||
let to: Vec<_> = to_tuples
|
||||
.map(|(name, addr)| {
|
||||
if name.is_empty() {
|
||||
Address::new_mailbox(addr.to_string())
|
||||
} else {
|
||||
Address::new_mailbox_with_name(name.to_string(), addr.to_string())
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
let mut message = email::MimeMessage::new_blank_message();
|
||||
message.headers.insert(
|
||||
(
|
||||
"Content-Type".to_string(),
|
||||
"text/plain; charset=utf-8; format=flowed; delsp=no".to_string(),
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
message
|
||||
.headers
|
||||
.insert(Header::new_with_value("To".into(), to).unwrap());
|
||||
message.body = "Hi".to_string();
|
||||
|
||||
let msg = message.as_string();
|
||||
|
||||
let header_end = msg.find("Hi").unwrap();
|
||||
#[allow(clippy::indexing_slicing)]
|
||||
let headers = msg[0..header_end].trim();
|
||||
|
||||
assert!(!headers.lines().any(|l| l.trim().is_empty()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user