Skip to content

Commit 6d63abd

Browse files
committed
Merge branch '6.2.x'
2 parents e81fcc3 + 2b4c7d0 commit 6d63abd

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
import java.util.Base64;
2424
import java.util.BitSet;
2525
import java.util.List;
26+
import java.util.Locale;
2627
import java.util.regex.Matcher;
2728
import java.util.regex.Pattern;
2829

@@ -252,7 +253,7 @@ public static ContentDisposition parse(String contentDisposition) {
252253
String part = parts.get(i);
253254
int eqIndex = part.indexOf('=');
254255
if (eqIndex != -1) {
255-
String attribute = part.substring(0, eqIndex);
256+
String attribute = part.substring(0, eqIndex).toLowerCase(Locale.ROOT);
256257
String value = (part.startsWith("\"", eqIndex + 1) && part.endsWith("\"") ?
257258
part.substring(eqIndex + 2, part.length() - 1) :
258259
part.substring(eqIndex + 1));

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -180,6 +180,14 @@ void parseWithExtraSemicolons() {
180180
.build());
181181
}
182182

183+
@Test
184+
void parseAttributesCaseInsensitively() {
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)