Polish contribution & Support multiple quoted printable segments in Content-Disposition
This commit polishes the contribution for support of multiple base64 segments, and adds supports for multiple quoted printable segments in Content-Disposition. Closes gh-28236
This commit is contained in:
@@ -87,10 +87,11 @@ class ContentDispositionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseBase64EncodedFilenameHasMoreSegments() {
|
||||
/* https://datatracker.ietf.org/doc/html/rfc2047#section-2
|
||||
* An 'encoded-word' may not be more than 75 characters long */
|
||||
String input = "attachment; filename=\"=?utf-8?B?U3ByaW5n5qGG5p625Li65Z+65LqOSmF2YeeahOeOsOS7o+S8geS4muW6lA==?= =?utf-8?B?55So56iL5bqP5o+Q5L6b5LqG5YWo6Z2i55qE57yW56iL5ZKM6YWN572u5qih?= =?utf-8?B?5Z6LLnR4dA==?=\"";
|
||||
void parseBase64EncodedFilenameMultipleSegments() {
|
||||
String input =
|
||||
"attachment; filename=\"=?utf-8?B?U3ByaW5n5qGG5p625Li65Z+65LqOSmF2YeeahOeOsOS7o+S8geS4muW6lA==?= " +
|
||||
"=?utf-8?B?55So56iL5bqP5o+Q5L6b5LqG5YWo6Z2i55qE57yW56iL5ZKM6YWN572u5qih?= " +
|
||||
"=?utf-8?B?5Z6LLnR4dA==?=\"";
|
||||
assertThat(parse(input).getFilename()).isEqualTo("Spring框架为基于Java的现代企业应用程序提供了全面的编程和配置模型.txt");
|
||||
}
|
||||
|
||||
@@ -106,6 +107,18 @@ class ContentDispositionTests {
|
||||
assertThat(parse(input).getFilename()).isEqualTo("日本語.csv");
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseQuotedPrintableFilenameMultipleSegments() {
|
||||
String input =
|
||||
"attachment; filename=\"=?utf-8?Q?Spring=E6=A1=86=E6=9E=B6=E4=B8=BA=E5=9F=BA=E4=BA=8E?=" +
|
||||
"=?utf-8?Q?Java=E7=9A=84=E7=8E=B0=E4=BB=A3=E4=BC=81=E4=B8=9A=E5=BA=94?=" +
|
||||
"=?utf-8?Q?=E7=94=A8=E7=A8=8B=E5=BA=8F=E6=8F=90=E4=BE=9B=E4=BA=86=E5=85=A8?=" +
|
||||
"=?utf-8?Q?=E9=9D=A2=E7=9A=84=E7=BC=96=E7=A8=8B=E5=92=8C=E9=85=8D=E7=BD=AE?=" +
|
||||
"=?utf-8?Q?=E6=A8=A1=E5=9E=8B.txt?=\"";
|
||||
assertThat(parse(input).getFilename()).isEqualTo("Spring框架为基于Java的现代企业应用程序提供了全面的编程和配置模型.txt");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseQuotedPrintableShiftJISFilename() {
|
||||
String input = "attachment; filename=\"=?SHIFT_JIS?Q?=93=FA=96{=8C=EA.csv?=\"";
|
||||
|
||||
Reference in New Issue
Block a user