From dbb1358449edbd53e5dc6c179796054b04c1e4a9 Mon Sep 17 00:00:00 2001 From: Yassir Barchi Date: Wed, 27 Mar 2024 19:03:08 +0100 Subject: [PATCH] test: add a regression test --- src/headers/writer.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/headers/writer.rs b/src/headers/writer.rs index 0da376e..a36e6ab 100644 --- a/src/headers/writer.rs +++ b/src/headers/writer.rs @@ -351,4 +351,24 @@ mod tests { ) ); } + + #[test] + fn double_spaces_issue_949() { + let mut s = "Subject: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ".to_string(); + let line_len = s.len(); + + { + let mut w = EmailWriter::new(&mut s, line_len, 0, false, true); + w.folding().write_str("BBBBBBBBBBBBB ").unwrap(); + crate::headers::rfc2047::encode("sélection", &mut w).unwrap(); + } + + assert_eq!( + s, + concat!( + "Subject: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA BBBBBBBBBBBBB\r\n", + " =?utf-8?b?c8OpbGVjdGlvbg==?=", + ) + ); + } }