Skip to content

Commit

Permalink
Use Locale.ROOT consistently for toLower/toUpperCase
Browse files Browse the repository at this point in the history
Closes gh-33708
  • Loading branch information
jhoeller committed Oct 16, 2024
1 parent 11d4272 commit c765d03
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -18,6 +18,7 @@

import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.util.Locale;
import java.util.Optional;
import java.util.function.Function;

Expand Down Expand Up @@ -192,7 +193,7 @@ private <A extends Annotation> boolean evaluateExpression(String expression, boo
return b;
}
else if (result instanceof String str) {
str = str.trim().toLowerCase();
str = str.trim().toLowerCase(Locale.ROOT);
if ("true".equals(str)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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.
Expand All @@ -19,6 +19,7 @@
import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -81,7 +82,7 @@ public final CompletableFuture<WebSocketSession> execute(WebSocketHandler webSoc
HttpHeaders headersToUse = new HttpHeaders();
if (headers != null) {
headers.forEach((header, values) -> {
if (values != null && !specialHeaders.contains(header.toLowerCase())) {
if (values != null && !specialHeaders.contains(header.toLowerCase(Locale.ROOT))) {
headersToUse.put(header, values);
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -23,6 +23,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -154,7 +155,7 @@ public RequestUpgradeStrategy getRequestUpgradeStrategy() {
public void setSupportedProtocols(String... protocols) {
this.supportedProtocols.clear();
for (String protocol : protocols) {
this.supportedProtocols.add(protocol.toLowerCase());
this.supportedProtocols.add(protocol.toLowerCase(Locale.ROOT));
}
}

Expand Down Expand Up @@ -329,10 +330,10 @@ protected boolean isValidOrigin(ServerHttpRequest request) {
protected String selectProtocol(List<String> requestedProtocols, WebSocketHandler webSocketHandler) {
List<String> handlerProtocols = determineHandlerSupportedProtocols(webSocketHandler);
for (String protocol : requestedProtocols) {
if (handlerProtocols.contains(protocol.toLowerCase())) {
if (handlerProtocols.contains(protocol.toLowerCase(Locale.ROOT))) {
return protocol;
}
if (this.supportedProtocols.contains(protocol.toLowerCase())) {
if (this.supportedProtocols.contains(protocol.toLowerCase(Locale.ROOT))) {
return protocol;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -16,6 +16,8 @@

package org.springframework.web.socket.sockjs.frame;

import java.util.Locale;

import org.springframework.util.Assert;

/**
Expand Down Expand Up @@ -58,7 +60,7 @@ private String escapeSockJsSpecialChars(char[] characters) {
for (char c : characters) {
if (isSockJsSpecialChar(c)) {
result.append('\\').append('u');
String hex = Integer.toHexString(c).toLowerCase();
String hex = Integer.toHexString(c).toLowerCase(Locale.ROOT);
result.append("0".repeat(Math.max(0, (4 - hex.length()))));
result.append(hex);
}
Expand Down

0 comments on commit c765d03

Please sign in to comment.