Support escape character in ContentDisposition

Closes gh-23077
This commit is contained in:
Rossen Stoyanchev
2019-06-03 16:03:35 -04:00
parent 4523d01a50
commit 4f05da7fed
2 changed files with 12 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -331,6 +331,7 @@ public final class ContentDisposition {
do {
int nextIndex = index + 1;
boolean quoted = false;
boolean escaped = false;
while (nextIndex < headerValue.length()) {
char ch = headerValue.charAt(nextIndex);
if (ch == ';') {
@@ -338,9 +339,10 @@ public final class ContentDisposition {
break;
}
}
else if (ch == '"') {
else if (!escaped && ch == '"') {
quoted = !quoted;
}
escaped = (!escaped && ch == '\\');
nextIndex++;
}
String part = headerValue.substring(index + 1, nextIndex).trim();