ContentDisposition trims charset in filename
Closes gh-24112
This commit is contained in:
parent
f180bf7652
commit
c8bce9686f
|
@ -282,7 +282,7 @@ public final class ContentDisposition {
|
|||
int idx1 = value.indexOf('\'');
|
||||
int idx2 = value.indexOf('\'', idx1 + 1);
|
||||
if (idx1 != -1 && idx2 != -1) {
|
||||
charset = Charset.forName(value.substring(0, idx1));
|
||||
charset = Charset.forName(value.substring(0, idx1).trim());
|
||||
Assert.isTrue(UTF_8.equals(charset) || ISO_8859_1.equals(charset),
|
||||
"Charset should be UTF-8 or ISO-8859-1");
|
||||
filename = decodeFilename(value.substring(idx2 + 1), charset);
|
||||
|
|
|
@ -70,6 +70,14 @@ public class ContentDispositionTests {
|
|||
.build());
|
||||
}
|
||||
|
||||
@Test // gh-24112
|
||||
public void parseEncodedFilenameWithPaddedCharset() {
|
||||
assertThat(parse("attachment; filename*= UTF-8''some-file.zip"))
|
||||
.isEqualTo(ContentDisposition.builder("attachment")
|
||||
.filename("some-file.zip", StandardCharsets.UTF_8)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseEncodedFilenameWithoutCharset() {
|
||||
assertThat(parse("form-data; name=\"name\"; filename*=test.txt"))
|
||||
|
|
Loading…
Reference in New Issue