Fix StringIndexOutOfBoundsException

Closes gh-29588
This commit is contained in:
rstoyanchev
2023-02-07 15:44:34 +00:00
parent 08e7f5a292
commit 9c0b28ffdc
3 changed files with 13 additions and 2 deletions

View File

@@ -488,7 +488,8 @@ public class MockHttpServletRequest implements HttpServletRequest {
}
catch (IllegalArgumentException ex) {
// 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) {
this.characterEncoding = contentType.substring(charsetIndex + CHARSET_PREFIX.length());
}