Skip to content

Commit

Permalink
8294378: URLPermission constructor exception when using tr locale
Browse files Browse the repository at this point in the history
Backport-of: ff2c987669523613f3e5dc19493a41f849f882f6
  • Loading branch information
GoeLin committed Jan 16, 2023
1 parent 6faa77c commit 8458368
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/java.base/share/classes/java/net/HostPortrange.java
Expand Up @@ -149,6 +149,9 @@ public int hashCode() {
// regular domain name
hoststr = toLowerCase(hoststr);
}
} else {
// regular domain name
hoststr = toLowerCase(hoststr);
}
}
hostname = hoststr;
Expand Down
5 changes: 3 additions & 2 deletions src/java.base/share/classes/java/net/URLPermission.java
Expand Up @@ -31,6 +31,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.security.Permission;
import java.util.Locale;

/**
* Represents permission to access a resource or set of resources defined by a
Expand Down Expand Up @@ -444,7 +445,7 @@ private void parseURI(String url) {
throw new IllegalArgumentException(
"Invalid URL string: \"" + url + "\"");
}
scheme = url.substring(0, delim).toLowerCase();
scheme = url.substring(0, delim).toLowerCase(Locale.ROOT);
this.ssp = url.substring(delim + 1);

if (!ssp.startsWith("//")) {
Expand All @@ -466,7 +467,7 @@ private void parseURI(String url) {
auth = authpath.substring(0, delim);
this.path = authpath.substring(delim);
}
this.authority = new Authority(scheme, auth.toLowerCase());
this.authority = new Authority(scheme, auth);
}

private String actions() {
Expand Down
10 changes: 7 additions & 3 deletions test/jdk/java/net/URLPermission/URLPermissionTest.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022, 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
Expand All @@ -26,7 +26,9 @@

/**
* @test
* @bug 8010464 8027570 8027687 8029354 8114860 8071660 8161291
* @bug 8010464 8027570 8027687 8029354 8114860 8071660 8161291 8294378
* @run main URLPermissionTest
* @run main/othervm -Duser.language=tr URLPermissionTest
*/

public class URLPermissionTest {
Expand Down Expand Up @@ -385,7 +387,9 @@ static URLEqualityTest eqtest(String arg1, String arg2, boolean expected) {
eqtest("http://michael@foo.com/bar","http://michael@foo.com/bar", true),
eqtest("http://Michael@foo.com/bar","http://michael@goo.com/bar",false),
eqtest("http://michael@foo.com/bar","http://george@foo.com/bar", true),
eqtest("http://@foo.com/bar","http://foo.com/bar", true)
eqtest("http://@foo.com/bar","http://foo.com/bar", true),
eqtest("http://www.IOU.com", "http://www.iou.com", true),
eqtest("HTTPI://www.IOU.com", "httpi://www.iou.com", true)
};

static Test[] createTests = {
Expand Down

1 comment on commit 8458368

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.