mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-21 05:09:13 +00:00
Ensure parsing/tostring symmetry in ContentDisposition
Prior to this commit, building a "Content-Disposition" header to a String and then parsing it back would not always result in the original header. This commit ensures that ContentDisposition guarantees this and honors the "equals" contract. Fixes gh-37064
This commit is contained in:
@@ -181,6 +181,15 @@ class ContentDispositionTests {
|
||||
assertThat(cd.getFilename()).isEqualTo("foo\\bar \"baz\" qux \\\" quux.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseBackslashInName() {
|
||||
String s = "form-data; name=\"foo\\\"bar\"; filename=\"foo.txt\"";
|
||||
ContentDisposition cd = ContentDisposition.parse(s);
|
||||
assertThat(cd.getName()).isEqualTo("foo\"bar");
|
||||
assertThat(cd.getFilename()).isEqualTo("foo.txt");
|
||||
assertThat(cd.toString()).isEqualTo(s);
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseBackslashInLastPosition() {
|
||||
ContentDisposition cd = ContentDisposition.parse("form-data; name=\"foo\"; filename=\"bar\\\"");
|
||||
|
||||
Reference in New Issue
Block a user