Merge branch '6.1.x'

This commit is contained in:
rstoyanchev
2024-10-16 12:11:23 +01:00
42 changed files with 97 additions and 74 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package org.springframework.web.servlet.mvc.condition;
import java.util.Locale;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
@@ -108,7 +110,7 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
@Override
public int hashCode() {
int result = (isCaseSensitiveName() ? this.name.hashCode() : this.name.toLowerCase().hashCode());
int result = (isCaseSensitiveName() ? this.name.hashCode() : this.name.toLowerCase(Locale.ROOT).hashCode());
result = 31 * result + (this.value != null ? this.value.hashCode() : 0);
result = 31 * result + (this.isNegated ? 1 : 0);
return result;

View File

@@ -532,7 +532,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
if (!StringUtils.hasText(extension)) {
return true;
}
extension = extension.toLowerCase(Locale.ENGLISH);
extension = extension.toLowerCase(Locale.ROOT);
if (this.safeExtensions.contains(extension)) {
return true;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
import jakarta.servlet.http.HttpServletRequest;
@@ -147,7 +148,7 @@ public class CachingResourceResolver extends AbstractResourceResolver {
return Arrays.stream(StringUtils.tokenizeToStringArray(header, ","))
.map(token -> {
int index = token.indexOf(';');
return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase();
return (index >= 0 ? token.substring(0, index) : token).trim().toLowerCase(Locale.ROOT);
})
.filter(this.contentCodings::contains)
.sorted()

View File

@@ -28,6 +28,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import jakarta.servlet.http.HttpServletRequest;
@@ -166,7 +167,7 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
@Nullable
private String getAcceptEncoding(HttpServletRequest request) {
String header = request.getHeader(HttpHeaders.ACCEPT_ENCODING);
return (header != null ? header.toLowerCase() : null);
return (header != null ? header.toLowerCase(Locale.ROOT) : null);
}
private String getExtension(String coding) {

View File

@@ -318,7 +318,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
*/
public void setMediaTypes(Map<String, MediaType> mediaTypes) {
mediaTypes.forEach((ext, mediaType) ->
this.mediaTypes.put(ext.toLowerCase(Locale.ENGLISH), mediaType));
this.mediaTypes.put(ext.toLowerCase(Locale.ROOT), mediaType));
}
/**
@@ -708,7 +708,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
String filename = resource.getFilename();
String ext = StringUtils.getFilenameExtension(filename);
if (ext != null) {
mediaType = this.mediaTypes.get(ext.toLowerCase(Locale.ENGLISH));
mediaType = this.mediaTypes.get(ext.toLowerCase(Locale.ROOT));
}
if (mediaType == null) {
List<MediaType> mediaTypes = MediaTypeFactory.getMediaTypes(filename);

View File

@@ -20,6 +20,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
@@ -417,7 +418,7 @@ public class XsltView extends AbstractUrlBasedView {
}
if (StringUtils.hasText(encoding)) {
// Only apply encoding if content type is specified but does not contain charset clause already.
if (contentType != null && !contentType.toLowerCase().contains(WebUtils.CONTENT_TYPE_CHARSET_PREFIX)) {
if (contentType != null && !contentType.toLowerCase(Locale.ROOT).contains(WebUtils.CONTENT_TYPE_CHARSET_PREFIX)) {
contentType = contentType + WebUtils.CONTENT_TYPE_CHARSET_PREFIX + encoding;
}
}