mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-22 14:09:25 +00:00
Reject duplicate MIME type parameters
Prior to this commit, MIME type parsing in Spring would allow duplicate parameters like "text/plain; dupe=1; dupe=2", effectively retaining the latest value and ignoring the first. RFC 6838 4.3 states that this should be treated as an error and this commit ensures that this is the case. Closes gh-36841
This commit is contained in:
+1
-1
@@ -237,7 +237,7 @@ class MockHttpServletRequestTests {
|
||||
|
||||
@Test // SPR-12677
|
||||
void setContentTypeHeaderWithMoreComplexCharsetSyntax() {
|
||||
String contentType = "test/plain;charset=\"utf-8\";foo=\"charset=bar\";foocharset=bar;foo=bar";
|
||||
String contentType = "test/plain;charset=\"utf-8\";foo=\"charset=bar\";foocharset=bar;foobar=bar";
|
||||
request.addHeader(HttpHeaders.CONTENT_TYPE, contentType);
|
||||
assertThat(request.getContentType()).isEqualTo(contentType);
|
||||
assertThat(request.getHeader(HttpHeaders.CONTENT_TYPE)).isEqualTo(contentType);
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@ class MockHttpServletResponseTests {
|
||||
|
||||
@Test // SPR-12677
|
||||
void shouldSetEncodingWithComplexContentTypeSyntax() {
|
||||
String contentType = "test/plain;charset=\"utf-8\";foo=\"charset=bar\";foocharset=bar;foo=bar";
|
||||
String contentType = "test/plain;charset=\"utf-8\";foo=\"charset=bar\";foocharset=bar;foobar=bar";
|
||||
response.setHeader(HttpHeaders.CONTENT_TYPE, contentType);
|
||||
assertThat(response.getContentType()).isEqualTo(contentType);
|
||||
assertThat(response.getHeader(HttpHeaders.CONTENT_TYPE)).isEqualTo(contentType);
|
||||
|
||||
Reference in New Issue
Block a user