mirror of
https://github.com/chatmail/core.git
synced 2026-05-15 12:56:30 +03:00
add test for apostrophed-encoded filenames
This commit is contained in:
@@ -1527,6 +1527,24 @@ mod tests {
|
|||||||
assert_eq!(filename, Some("=?utf-8?q?foo?=.bar".to_string()))
|
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]
|
#[test]
|
||||||
fn test_get_attachment_filename_combined() {
|
fn test_get_attachment_filename_combined() {
|
||||||
// test that if `filename` and `filename*0` are given, the filename is not doubled
|
// test that if `filename` and `filename*0` are given, the filename is not doubled
|
||||||
|
|||||||
24
test-data/message/attach_filename_apostrophed.eml
Normal file
24
test-data/message/attach_filename_apostrophed.eml
Normal file
@@ -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==--
|
||||||
34
test-data/message/attach_filename_apostrophed_cont.eml
Normal file
34
test-data/message/attach_filename_apostrophed_cont.eml
Normal file
@@ -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==--
|
||||||
Reference in New Issue
Block a user