ContentDisposition refactoring

See gh-24220
This commit is contained in:
Rossen Stoyanchev
2019-12-26 17:30:15 +00:00
parent 3cf806a668
commit 956ffe6858
2 changed files with 34 additions and 23 deletions

View File

@@ -222,10 +222,15 @@ public class ContentDispositionTests {
@Test // gh-24220
public void formatWithFilenameWithQuotes() {
BiConsumer<String, String> tester = (input, output) ->
BiConsumer<String, String> tester = (input, output) -> {
assertThat(builder("form-data").filename(input).build().toString())
.isEqualTo("form-data; filename=\"" + output + "\"");
assertThat(builder("form-data").filename(input, StandardCharsets.US_ASCII).build().toString())
.isEqualTo("form-data; filename=\"" + output + "\"");
};
String filename = "\"foo.txt";
tester.accept(filename, "\\" + filename);
@@ -243,6 +248,10 @@ public class ContentDispositionTests {
tester.accept("\"\"foo.txt", "\\\"\\\"foo.txt");
tester.accept("\"\"\"foo.txt", "\\\"\\\"\\\"foo.txt");
tester.accept("foo.txt\\", "foo.txt");
tester.accept("foo.txt\\\\", "foo.txt\\\\");
tester.accept("foo.txt\\\\\\", "foo.txt\\\\");
}
@Test