Skip to content

Commit 853b13f

Browse files
dobrosidobrosi.andras
authored and
dobrosi.andras
committed
File name is null bug fixed
Signed-off-by: Andras Dobrosi <dobrosi@gmail.com>
1 parent 0c73901 commit 853b13f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

spring-web/src/main/java/org/springframework/http/ContentDisposition.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public static ContentDisposition parse(String contentDisposition) {
252252
String part = parts.get(i);
253253
int eqIndex = part.indexOf('=');
254254
if (eqIndex != -1) {
255-
String attribute = part.substring(0, eqIndex);
255+
String attribute = part.substring(0, eqIndex).toLowerCase();
256256
String value = (part.startsWith("\"", eqIndex + 1) && part.endsWith("\"") ?
257257
part.substring(eqIndex + 2, part.length() - 1) :
258258
part.substring(eqIndex + 1));

spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java

+8
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ void parseWithExtraSemicolons() {
180180
.build());
181181
}
182182

183+
@Test
184+
void parseAttributesCaseIgnore() {
185+
ContentDisposition cd = ContentDisposition.parse("form-data; Name=\"foo\"; FileName=\"bar.txt\"");
186+
assertThat(cd.getName()).isEqualTo("foo");
187+
assertThat(cd.getFilename()).isEqualTo("bar.txt");
188+
assertThat(cd.toString()).isEqualTo("form-data; name=\"foo\"; filename=\"bar.txt\"");
189+
}
190+
183191
@Test
184192
void parseEmpty() {
185193
assertThatIllegalArgumentException().isThrownBy(() -> parse(""));

0 commit comments

Comments
 (0)