From 7e93dbb0735cb3c8e9be7ff8b214141ab3c67929 Mon Sep 17 00:00:00 2001 From: Stefan Ortgies Date: Wed, 10 May 2023 16:01:12 +0200 Subject: [PATCH 1/3] Added Test --- .../java/jakarta/mail/internet/ParameterListTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/api/src/test/java/jakarta/mail/internet/ParameterListTest.java b/api/src/test/java/jakarta/mail/internet/ParameterListTest.java index 9f7ad0d2..3ef5c3d8 100644 --- a/api/src/test/java/jakarta/mail/internet/ParameterListTest.java +++ b/api/src/test/java/jakarta/mail/internet/ParameterListTest.java @@ -71,4 +71,14 @@ public void testLongSet() throws Exception { assertTrue(pls.indexOf("p*0=") >= 0); assertTrue(pls.indexOf("p*1=") >= 0); } + + @Test + public void testQEncoding() throws Exception { + String disposition = ";\n" + + " filename==?utf-8?Q?XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--111111111-XXXXXXXXXXXXXXXXXXX?=\n" + + " =?utf-8?Q?XXXXXXXXXXXXXXXXXXX=2Epdf?=;\n" + + " filename*0*=utf-8''XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--111111111-XXXXXXXXXXX;\n" + + " filename*1*=XXXXXXXXXXXXXXXXXXXXXXXXXXX.pdf"; + new ParameterList(disposition); + } } From 25d99bd561cd203a543c49e8cd2ab1055e3589b8 Mon Sep 17 00:00:00 2001 From: Stefan Ortgies Date: Wed, 10 May 2023 16:28:48 +0200 Subject: [PATCH 2/3] Added test --- .../mail/internet/ParameterListTest.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/api/src/test/java/jakarta/mail/internet/ParameterListTest.java b/api/src/test/java/jakarta/mail/internet/ParameterListTest.java index 3ef5c3d8..1bf06347 100644 --- a/api/src/test/java/jakarta/mail/internet/ParameterListTest.java +++ b/api/src/test/java/jakarta/mail/internet/ParameterListTest.java @@ -71,14 +71,33 @@ public void testLongSet() throws Exception { assertTrue(pls.indexOf("p*0=") >= 0); assertTrue(pls.indexOf("p*1=") >= 0); } - + + @Test + public void testUtf8() throws Exception { + String disposition = ";\n" + + " filename*0*=utf-8''XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--111111111-XXXXXXXXXXX;\n" + + " filename*1*=XXXXXXXXXXXXXXXXXXXXXXXXXXX.pdf"; + ParameterList parameterList = new ParameterList(disposition); + assertEquals("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--111111111-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pdf", parameterList.get("filename")); + } + @Test public void testQEncoding() throws Exception { + String disposition = ";\n" + + " filename==?utf-8?Q?XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--111111111-XXXXXXXXXXXXXXXXXXX?=\n" + + " =?utf-8?Q?XXXXXXXXXXXXXXXXXXX=2Epdf?=;"; + ParameterList parameterList = new ParameterList(disposition); + assertEquals("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--111111111-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pdf", parameterList.get("filename")); + } + + @Test + public void testQEncodingAndUtf8() throws Exception { String disposition = ";\n" + " filename==?utf-8?Q?XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--111111111-XXXXXXXXXXXXXXXXXXX?=\n" + " =?utf-8?Q?XXXXXXXXXXXXXXXXXXX=2Epdf?=;\n" + " filename*0*=utf-8''XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--111111111-XXXXXXXXXXX;\n" + " filename*1*=XXXXXXXXXXXXXXXXXXXXXXXXXXX.pdf"; - new ParameterList(disposition); + ParameterList parameterList = new ParameterList(disposition); + assertEquals("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--111111111-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pdf", parameterList.get("filename")); } } From 352ef669e60cd0c3de1a71125791871f0bcaa29f Mon Sep 17 00:00:00 2001 From: Stefan Ortgies Date: Wed, 10 May 2023 16:29:26 +0200 Subject: [PATCH 3/3] fixed parameter order of assertEquals --- api/src/test/java/jakarta/mail/internet/ParameterListTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/test/java/jakarta/mail/internet/ParameterListTest.java b/api/src/test/java/jakarta/mail/internet/ParameterListTest.java index 1bf06347..a015da66 100644 --- a/api/src/test/java/jakarta/mail/internet/ParameterListTest.java +++ b/api/src/test/java/jakarta/mail/internet/ParameterListTest.java @@ -41,7 +41,7 @@ public static void before() { public void testBackslash() throws Exception { System.clearProperty("mail.mime.windowsfilenames"); ParameterList pl = new ParameterList("; filename=\"\\a\\b\\c.txt\""); - assertEquals(pl.get("filename"), "abc.txt"); + assertEquals("abc.txt", pl.get("filename")); } /**