Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public static ContentDisposition parse(String contentDisposition) {
String part = parts.get(i);
int eqIndex = part.indexOf('=');
if (eqIndex != -1) {
String attribute = part.substring(0, eqIndex);
String attribute = part.substring(0, eqIndex).toLowerCase();
String value = (part.startsWith("\"", eqIndex + 1) && part.endsWith("\"") ?
part.substring(eqIndex + 2, part.length() - 1) :
part.substring(eqIndex + 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ void parseWithExtraSemicolons() {
.build());
}

@Test
void parseAttributesCaseInsensitively() {
ContentDisposition cd = ContentDisposition.parse("form-data; Name=\"foo\"; FileName=\"bar.txt\"");
assertThat(cd.getName()).isEqualTo("foo");
assertThat(cd.getFilename()).isEqualTo("bar.txt");
assertThat(cd.toString()).isEqualTo("form-data; name=\"foo\"; filename=\"bar.txt\"");
}

@Test
void parseEmpty() {
assertThatIllegalArgumentException().isThrownBy(() -> parse(""));
Expand Down
Loading