Use Locale.ROOT consistently for toLower/toUpperCase

See gh-33708
This commit is contained in:
rstoyanchev
2024-10-16 12:05:13 +01:00
parent feb6a5f52d
commit 23656aebc6
43 changed files with 106 additions and 82 deletions

View File

@@ -409,7 +409,8 @@ public class MockHttpServletRequest implements HttpServletRequest {
private void updateContentTypeHeader() {
if (StringUtils.hasLength(this.contentType)) {
String value = this.contentType;
if (StringUtils.hasLength(this.characterEncoding) && !this.contentType.toLowerCase().contains(CHARSET_PREFIX)) {
if (StringUtils.hasLength(this.characterEncoding) &&
!this.contentType.toLowerCase(Locale.ROOT).contains(CHARSET_PREFIX)) {
value += ';' + CHARSET_PREFIX + this.characterEncoding;
}
doAddHeaderValue(HttpHeaders.CONTENT_TYPE, value, true);
@@ -487,7 +488,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
}
catch (IllegalArgumentException ex) {
// Try to get charset value anyway
contentType = contentType.toLowerCase();
contentType = contentType.toLowerCase(Locale.ROOT);
int charsetIndex = contentType.indexOf(CHARSET_PREFIX);
if (charsetIndex != -1) {
this.characterEncoding = contentType.substring(charsetIndex + CHARSET_PREFIX.length());

View File

@@ -223,7 +223,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
}
catch (Exception ignored) {
String value = this.contentType;
int charsetIndex = value.toLowerCase().indexOf(CHARSET_PREFIX);
int charsetIndex = value.toLowerCase(Locale.ROOT).indexOf(CHARSET_PREFIX);
if (charsetIndex != -1) {
value = value.substring(0, charsetIndex).trim();
if (value.endsWith(";")) {
@@ -243,7 +243,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
private void updateContentTypePropertyAndHeader() {
if (this.contentType != null) {
String value = this.contentType;
if (this.characterEncodingSet && !value.toLowerCase().contains(CHARSET_PREFIX)) {
if (this.characterEncodingSet && !value.toLowerCase(Locale.ROOT).contains(CHARSET_PREFIX)) {
value += ';' + CHARSET_PREFIX + getCharacterEncoding();
this.contentType = value;
}
@@ -351,7 +351,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
}
catch (Exception ex) {
// Try to get charset value anyway
int charsetIndex = contentType.toLowerCase().indexOf(CHARSET_PREFIX);
int charsetIndex = contentType.toLowerCase(Locale.ROOT).indexOf(CHARSET_PREFIX);
if (charsetIndex != -1) {
setExplicitCharacterEncoding(contentType.substring(charsetIndex + CHARSET_PREFIX.length()));
}