diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 21d03e029..8086d6eb4 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -1489,6 +1489,15 @@ mod tests { assert_eq!(filename, Some("Maßnahmen Okt. 2020.html".to_string())) } + #[test] + fn test_get_attachment_filename_encoded_words_binary() { + let mail = load_mail_with_attachment(include_bytes!( + "../test-data/message/attach_filename_encoded_words_binary.eml" + )); + let filename = get_attachment_filename(&mail.subparts[1]).unwrap(); + assert_eq!(filename, Some(" § 165 Abs".to_string())) + } + #[test] fn test_get_attachment_filename_encoded_words_cont() { // test continued encoded-words and also test apostropes work that way diff --git a/test-data/message/attach_filename_encoded_words_binary.eml b/test-data/message/attach_filename_encoded_words_binary.eml new file mode 100644 index 000000000..e028f1340 --- /dev/null +++ b/test-data/message/attach_filename_encoded_words_binary.eml @@ -0,0 +1,26 @@ +Subject: Test binary-encoded-words filenames +Message-ID: 123456@testrun.org +Date: Sat, 07 Dec 2019 19:00:27 +0000 +Chat-Version: 1.0 +To: recp@testrun.org +From: sender@testrun.org +Content-Type: multipart/mixed; boundary="==BREAK==" + + +--==BREAK== +Content-Type: text/plain; charset=utf-8 + +test binary word-encoded filename, +filename is " § 165 Abs" - note the leading space. + +as a side-effect, this also tests that the encoding-name +also works in UPPERCASE. + +--==BREAK== +Content-Type: text/html +Content-Disposition: attachment; filename="=?UTF-8?B?IMKnIDE2NSBBYnM=?="; +Content-Transfer-Encoding: base64 + +PGh0bWw+PGJvZHk+dGV4dDwvYm9keT5kYXRh + +--==BREAK==--