diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 9d952612b..6162d4719 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -1527,6 +1527,24 @@ mod tests { assert_eq!(filename, Some("=?utf-8?q?foo?=.bar".to_string())) } + #[test] + fn test_get_attachment_filename_apostrophed() { + let mail = load_mail_with_attachment(include_bytes!( + "../test-data/message/attach_filename_apostrophed.eml" + )); + let filename = get_attachment_filename(&mail.subparts[1]).unwrap(); + assert_eq!(filename, Some("Maßnahmen Okt. 2021.html".to_string())) + } + + #[test] + fn test_get_attachment_filename_apostrophed_cont() { + let mail = load_mail_with_attachment(include_bytes!( + "../test-data/message/attach_filename_apostrophed_cont.eml" + )); + let filename = get_attachment_filename(&mail.subparts[1]).unwrap(); + assert_eq!(filename, Some("Maßnahmen März 2022.html".to_string())) + } + #[test] fn test_get_attachment_filename_combined() { // test that if `filename` and `filename*0` are given, the filename is not doubled diff --git a/test-data/message/attach_filename_apostrophed.eml b/test-data/message/attach_filename_apostrophed.eml new file mode 100644 index 000000000..f45d4826e --- /dev/null +++ b/test-data/message/attach_filename_apostrophed.eml @@ -0,0 +1,24 @@ +Subject: Test apostrophed filenames +Message-ID: 12345@testrun.org +Date: Sat, 07 Dec 2019 19:00:27 +0000 +X-Mailer: Kopano 8.7.16 +To: recp@testrun.org +From: sender@testrun.org +Content-Type: multipart/mixed; boundary="==BREAK==" + + +--==BREAK== +Content-Type: text/plain; charset=utf-8 + +apostrophed filenames as of +https://tools.ietf.org/html/rfc2231 + +--==BREAK== +Content-Type: text/html +Content-Disposition: attachment; + filename*=utf-8''Ma%C3%9Fnahmen%20Okt.%202021.html +Content-Transfer-Encoding: base64 + +PGh0bWw+PGJvZHk+dGV4dDwvYm9keT5kYXRh + +--==BREAK==-- diff --git a/test-data/message/attach_filename_apostrophed_cont.eml b/test-data/message/attach_filename_apostrophed_cont.eml new file mode 100644 index 000000000..b7d9cf6a4 --- /dev/null +++ b/test-data/message/attach_filename_apostrophed_cont.eml @@ -0,0 +1,34 @@ +Subject: Test apostrophed filenames +Message-ID: 12345@testrun.org +Date: Sat, 07 Dec 2019 19:00:27 +0000 +X-Mailer: Kopano 8.7.16 +To: recp@testrun.org +From: sender@testrun.org +Content-Type: multipart/mixed; boundary="==BREAK==" + + +--==BREAK== +Content-Type: text/plain; charset=utf-8 + +apostrophed filenames as of +https://tools.ietf.org/html/rfc2231, +span over several header lines. + +note, that, in contrast to encoded-words, +the character-set is not repeated. + +as a side-effect, +this tests unquoted header attributes in filename*1* +and lower-case-urlencoded utf-8 + +--==BREAK== +Content-Type: text/html +Content-Disposition: attachment; + filename*0*="utf-8''Ma%C3%9Fna"; + filename*1*=hm; + filename*2*="en%20M%c3%a4rz%202022.html"; +Content-Transfer-Encoding: base64 + +PGh0bWw+PGJvZHk+dGV4dDwvYm9keT5kYXRh + +--==BREAK==--