parent
08e7f5a292
commit
9c0b28ffdc
|
@ -488,7 +488,8 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
catch (IllegalArgumentException ex) {
|
||||||
// Try to get charset value anyway
|
// Try to get charset value anyway
|
||||||
int charsetIndex = contentType.toLowerCase().indexOf(CHARSET_PREFIX);
|
contentType = contentType.toLowerCase();
|
||||||
|
int charsetIndex = contentType.indexOf(CHARSET_PREFIX);
|
||||||
if (charsetIndex != -1) {
|
if (charsetIndex != -1) {
|
||||||
this.characterEncoding = contentType.substring(charsetIndex + CHARSET_PREFIX.length());
|
this.characterEncoding = contentType.substring(charsetIndex + CHARSET_PREFIX.length());
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,6 +185,15 @@ class MockHttpServletRequestTests {
|
||||||
assertThat(request.getCharacterEncoding()).isEqualTo("UTF-8");
|
assertThat(request.getCharacterEncoding()).isEqualTo("UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test // gh-29255
|
||||||
|
void setContentTypeInvalidWithNonAsciiCharacterAndCharset() {
|
||||||
|
String contentType = "İcharset=";
|
||||||
|
request.addHeader(HttpHeaders.CONTENT_TYPE, contentType);
|
||||||
|
assertThat(request.getContentType()).isEqualTo(contentType);
|
||||||
|
assertThat(request.getHeader(HttpHeaders.CONTENT_TYPE)).isEqualTo(contentType);
|
||||||
|
assertThat(request.getCharacterEncoding()).isEqualTo("");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void contentTypeHeader() {
|
void contentTypeHeader() {
|
||||||
String contentType = "test/plain";
|
String contentType = "test/plain";
|
||||||
|
|
|
@ -488,7 +488,8 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
catch (IllegalArgumentException ex) {
|
||||||
// Try to get charset value anyway
|
// Try to get charset value anyway
|
||||||
int charsetIndex = contentType.toLowerCase().indexOf(CHARSET_PREFIX);
|
contentType = contentType.toLowerCase();
|
||||||
|
int charsetIndex = contentType.indexOf(CHARSET_PREFIX);
|
||||||
if (charsetIndex != -1) {
|
if (charsetIndex != -1) {
|
||||||
this.characterEncoding = contentType.substring(charsetIndex + CHARSET_PREFIX.length());
|
this.characterEncoding = contentType.substring(charsetIndex + CHARSET_PREFIX.length());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue