diff --git a/api/src/test/java/jakarta/mail/internet/ParameterListTest.java b/api/src/test/java/jakarta/mail/internet/ParameterListTest.java index 9f7ad0d2..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")); } /** @@ -71,4 +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"; + ParameterList parameterList = new ParameterList(disposition); + assertEquals("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--111111111-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pdf", parameterList.get("filename")); + } }