File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
main/java/org/springframework/http
test/java/org/springframework/http Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2018 the original author or authors.
2
+ * Copyright 2002-2019 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.
@@ -331,16 +331,18 @@ private static List<String> tokenize(String headerValue) {
331
331
do {
332
332
int nextIndex = index + 1 ;
333
333
boolean quoted = false ;
334
+ boolean escaped = false ;
334
335
while (nextIndex < headerValue .length ()) {
335
336
char ch = headerValue .charAt (nextIndex );
336
337
if (ch == ';' ) {
337
338
if (!quoted ) {
338
339
break ;
339
340
}
340
341
}
341
- else if (ch == '"' ) {
342
+ else if (! escaped && ch == '"' ) {
342
343
quoted = !quoted ;
343
344
}
345
+ escaped = (!escaped && ch == '\\' );
344
346
nextIndex ++;
345
347
}
346
348
String part = headerValue .substring (index + 1 , nextIndex ).trim ();
Original file line number Diff line number Diff line change @@ -79,6 +79,14 @@ public void parseEncodedFilename() {
79
79
.filename ("中文.txt" , StandardCharsets .UTF_8 ).build (), disposition );
80
80
}
81
81
82
+ @ Test // gh-23077
83
+ public void parseWithEscapedQuote () {
84
+ ContentDisposition disposition = ContentDisposition .parse (
85
+ "form-data; name=\" file\" ; filename=\" \\ \" The Twilight Zone\\ \" .txt\" ; size=123" );
86
+ assertEquals (ContentDisposition .builder ("form-data" ).name ("file" )
87
+ .filename ("\\ \" The Twilight Zone\\ \" .txt" ).size (123L ).build (), disposition );
88
+ }
89
+
82
90
@ Test (expected = IllegalArgumentException .class )
83
91
public void parseEmpty () {
84
92
ContentDisposition .parse ("" );
You can’t perform that action at this time.
0 commit comments