File tree 2 files changed +12
-3
lines changed
main/java/org/springframework/http
test/java/org/springframework/http
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2024 the original author or authors.
2
+ * Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
23
23
import java .util .Base64 ;
24
24
import java .util .BitSet ;
25
25
import java .util .List ;
26
+ import java .util .Locale ;
26
27
import java .util .regex .Matcher ;
27
28
import java .util .regex .Pattern ;
28
29
@@ -252,7 +253,7 @@ public static ContentDisposition parse(String contentDisposition) {
252
253
String part = parts .get (i );
253
254
int eqIndex = part .indexOf ('=' );
254
255
if (eqIndex != -1 ) {
255
- String attribute = part .substring (0 , eqIndex );
256
+ String attribute = part .substring (0 , eqIndex ). toLowerCase ( Locale . ROOT ) ;
256
257
String value = (part .startsWith ("\" " , eqIndex + 1 ) && part .endsWith ("\" " ) ?
257
258
part .substring (eqIndex + 2 , part .length () - 1 ) :
258
259
part .substring (eqIndex + 1 ));
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2024 the original author or authors.
2
+ * Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -180,6 +180,14 @@ void parseWithExtraSemicolons() {
180
180
.build ());
181
181
}
182
182
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
+
183
191
@ Test
184
192
void parseEmpty () {
185
193
assertThatIllegalArgumentException ().isThrownBy (() -> parse ("" ));
You can’t perform that action at this time.
0 commit comments