Avoid StringBuilder.append(Object) in ContentDisposition

This commit avoids invoking StringBuilder.append(Object) in favor
of explicit method calls to append(String) and append(char) in
ContentDisposition.escapeQuotationsInFilename(String).

Closes gh-25056
This commit is contained in:
Сергей Цыпанов 2020-05-12 19:36:31 +03:00 committed by GitHub
parent 311b333814
commit 6305a69cc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -39,6 +39,7 @@ import static java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME;
* @author Sebastien Deleuze
* @author Juergen Hoeller
* @author Rossen Stoyanchev
* @author Sergey Tsypanov
* @since 5.0
* @see <a href="https://tools.ietf.org/html/rfc6266">RFC 6266</a>
*/
@ -436,7 +437,11 @@ public final class ContentDisposition {
boolean escaped = false;
StringBuilder sb = new StringBuilder();
for (char c : filename.toCharArray()) {
sb.append((c == '"' && !escaped) ? "\\\"" : c);
if (!escaped && c == '"') {
sb.append("\\\"");
} else {
sb.append(c);
}
escaped = (!escaped && c == '\\');
}
// Remove backslash at the end..