RFR: 8297569: URLPermission constructor throws IllegalArgumentException: Invalid characters in hostname after JDK-8294378
Jaikiran Pai
jpai at openjdk.org
Thu Nov 24 12:28:56 UTC 2022
Can I please get a review of this change which proposes to fix https://bugs.openjdk.org/browse/JDK-8297569?
Recently we fixed a bug in `java.net.URLPermission` where that class used to run into an exception while trying to convert a hostname into lowercase, when run in Turkish locale https://bugs.openjdk.org/browse/JDK-8294378. The approach we decided to take in that fix was to use an internal `HostPortRange.toLowerCase` method which was unaffected by `Locale`s. The other alternative was to use `String.toLowerCase(Locale.ROOT)`, but we decided to use the former since it was already being used in other parts of the code in that area.
The implementation of `HostPortRange.toLowerCase` is very strict and it allows only a specific set of characters. The `_` (underscore character) isn't one of them. Before the change we did there, a `URLPermission` constructor could be passed a string `http://foo_bar` and it used to construct the instance successfully. However, after that change, it now fails with the exception noted in the issue.
The commit here reverts the previous fix and instead now uses `String.toLowerCase(Locale.ROOT)` to lowercase the authority. Additionally, an `else` block that we had introduced in the previous fix has been removed to bring us back to the old behaviour.
The test has been updated to include `http://foo_bar` (and its one more variant) string to construct the `URLPermission` instance.
JCK testing with the changes in this PR passed and other `tier` testing is currently in progress.
-------------
Commit messages:
- 8297569: URLPermission constructor throws IllegalArgumentException: Invalid characters in hostname after JDK-8294378
Changes: https://git.openjdk.org/jdk/pull/11353/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=11353&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8297569
Stats: 7 lines in 3 files changed: 2 ins; 3 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/11353.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/11353/head:pull/11353
PR: https://git.openjdk.org/jdk/pull/11353
More information about the net-dev
mailing list