mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
7065228: To interpret case-insensitive string locale independently
Reviewed-by: dfuchs, naoto, djelinski, jpai, michaelm
This commit is contained in:
parent
a9705196ce
commit
05e99db466
20 changed files with 74 additions and 60 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -370,7 +370,7 @@ public final class HttpCookie implements Cloneable {
|
|||
*/
|
||||
public void setDomain(String pattern) {
|
||||
if (pattern != null)
|
||||
domain = pattern.toLowerCase();
|
||||
domain = pattern.toLowerCase(Locale.ROOT);
|
||||
else
|
||||
domain = pattern;
|
||||
}
|
||||
|
@ -743,8 +743,8 @@ public final class HttpCookie implements Cloneable {
|
|||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int h1 = name.toLowerCase().hashCode();
|
||||
int h2 = (domain!=null) ? domain.toLowerCase().hashCode() : 0;
|
||||
int h1 = name.toLowerCase(Locale.ROOT).hashCode();
|
||||
int h2 = (domain!=null) ? domain.toLowerCase(Locale.ROOT).hashCode() : 0;
|
||||
int h3 = (path!=null) ? path.hashCode() : 0;
|
||||
|
||||
return h1 + h2 + h3;
|
||||
|
@ -977,7 +977,7 @@ public final class HttpCookie implements Cloneable {
|
|||
// strip off the surrounding "-sign if there's any
|
||||
attrValue = stripOffSurroundingQuote(attrValue);
|
||||
|
||||
CookieAttributeAssignor assignor = assignors.get(attrName.toLowerCase());
|
||||
CookieAttributeAssignor assignor = assignors.get(attrName.toLowerCase(Locale.ROOT));
|
||||
if (assignor != null) {
|
||||
assignor.assign(cookie, attrName, attrValue);
|
||||
} else {
|
||||
|
@ -1079,7 +1079,7 @@ public final class HttpCookie implements Cloneable {
|
|||
private static int guessCookieVersion(String header) {
|
||||
int version = 0;
|
||||
|
||||
header = header.toLowerCase();
|
||||
header = header.toLowerCase(Locale.ROOT);
|
||||
if (header.contains("expires=")) {
|
||||
// only netscape cookie using 'expires'
|
||||
version = 0;
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.io.ObjectInputStream;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.ObjectStreamField;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -137,7 +138,7 @@ public class InetSocketAddress
|
|||
if (addr != null)
|
||||
return addr.hashCode() + port;
|
||||
if (hostname != null)
|
||||
return hostname.toLowerCase().hashCode() + port;
|
||||
return hostname.toLowerCase(Locale.ROOT).hashCode() + port;
|
||||
return port;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import java.security.PermissionCollection;
|
|||
import java.security.PrivilegedAction;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.StringTokenizer;
|
||||
|
@ -460,7 +461,7 @@ public final class SocketPermission extends Permission
|
|||
if (host.equals("*")) {
|
||||
cname = "";
|
||||
} else if (host.startsWith("*.")) {
|
||||
cname = host.substring(1).toLowerCase();
|
||||
cname = host.substring(1).toLowerCase(Locale.ROOT);
|
||||
} else {
|
||||
throw new
|
||||
IllegalArgumentException("invalid host wildcard specification");
|
||||
|
@ -670,10 +671,10 @@ public final class SocketPermission extends Permission
|
|||
// we have to do this check, otherwise we might not
|
||||
// get the fully qualified domain name
|
||||
if (init_with_ip) {
|
||||
cname = addresses[0].getHostName(false).toLowerCase();
|
||||
cname = addresses[0].getHostName(false).toLowerCase(Locale.ROOT);
|
||||
} else {
|
||||
cname = InetAddress.getByName(addresses[0].getHostAddress()).
|
||||
getHostName(false).toLowerCase();
|
||||
getHostName(false).toLowerCase(Locale.ROOT);
|
||||
}
|
||||
} catch (UnknownHostException uhe) {
|
||||
invalid = true;
|
||||
|
@ -696,8 +697,8 @@ public final class SocketPermission extends Permission
|
|||
}
|
||||
|
||||
private boolean match(String cname, String hname) {
|
||||
String a = checkForIDN(cname.toLowerCase());
|
||||
String b = checkForIDN(hname.toLowerCase());
|
||||
String a = checkForIDN(cname.toLowerCase(Locale.ROOT));
|
||||
String b = checkForIDN(hname.toLowerCase(Locale.ROOT));
|
||||
if (a.startsWith(b) &&
|
||||
((a.length() == b.length()) || (a.charAt(b.length()) == '.'))) {
|
||||
return true;
|
||||
|
|
|
@ -38,6 +38,7 @@ import java.util.ServiceConfigurationError;
|
|||
import java.util.ServiceLoader;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.security.Permission;
|
||||
|
@ -1454,7 +1455,7 @@ public abstract class URLConnection {
|
|||
*/
|
||||
private String typeToPackageName(String contentType) {
|
||||
// make sure we canonicalize the class name: all lower case
|
||||
contentType = contentType.toLowerCase();
|
||||
contentType = contentType.toLowerCase(Locale.ROOT);
|
||||
int len = contentType.length();
|
||||
char nm[] = new char[len];
|
||||
contentType.getChars(0, len, nm, 0);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -26,6 +26,7 @@
|
|||
package java.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import sun.net.util.IPAddressUtil;
|
||||
|
||||
|
@ -374,7 +375,7 @@ public abstract class URLStreamHandler {
|
|||
} else {
|
||||
String host = u.getHost();
|
||||
if (host != null)
|
||||
h += host.toLowerCase().hashCode();
|
||||
h += host.toLowerCase(Locale.ROOT).hashCode();
|
||||
}
|
||||
|
||||
// Generate the file part.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue