On Mon, 5 Oct 2026 15:42:03 GMT, Arnt Gulbrandsen <[email protected]> wrote:

> `java.net.IDN` still implements IDNA2003, which is frozen at Unicode 3.2. 
> This PR moves it to UTS46 (IDNA2008 with the Unicode compatibility mapping), 
> which is what the big three browsers and most other languages' IDN libraries 
> use.
> 
> Names such as faß.de have been registrable since 2010, and today `IDN` turns 
> that into fass.de, which is a different domain.
> 
> ### Changes
> 
> The implementation is ICU4J's UTS46 code, merged into `jdk.internal.icu` with 
> the smallest reasonable diff. The UTS46 data (`uts46.nrm`) is generated from 
> Unicode 17, the same version as `Character`, so `IDN` can follow future 
> Unicode upgrades instead of being stuck at 3.2.
> 
> This patch removes the IDNA2003 code and its data file, 
> `sun/net/idn/uidna.spp`,and does not merge the ICU code that only registries 
> need.
> 
> I also fixed a typo in ICU's `Punycode.isBasicUpperCase()`.
> 
> There are three new public constants:
> 
> - `CHECK_CONTEXTJ` rejects ZWJ/ZWNJ (U+200D, U+200C) in contexts where 
> RFC5892 doesn't allow them.
> - `NONTRANSITIONAL_TO_ASCII` maps ß, ς, ZWJ and ZWNJ to themselves rather 
> than to ss, σ and nothing. This is what registries and browsers do now.
> - `NONTRANSITIONAL_TO_UNICODE` is the same, for `toUnicode()`.
> 
> `ALLOW_UNASSIGNED` is kept for source compatibility but ignored, since UTS46 
> knows the whole Unicode repertoire of the running JVM.
> 
> The one-argument `toASCII()` and `toUnicode()` now use 
> `CHECK_CONTEXTJ|NONTRANSITIONAL_TO_…`. Before, they used no flags.
> 
> ### Behaviour, before and after
> 
> Here are the results from JDK 27 and from this branch.
> 
> | Input | Call | JDK 27 | This PR |
> |---|---|---|---|
> | grå.org | `toASCII(s)` | xn--gr-zia.org | xn--gr-zia.org |
> | 例子.中国 | `toASCII(s)` | xn--fsqu00a.xn--fiqs8s | xn--fsqu00a.xn--fiqs8s |
> | faß.de | `toASCII(s)` | fass.de | xn--fa-hia.de |
> | faß.de | `toASCII(s, 0)` | fass.de | fass.de |
> | GRÅ.ORG | `toASCII(s)` | xn--gr-zia.ORG | xn--gr-zia.org |
> | a&lt;U+200D&gt;b.example.com | `toASCII(s)` | ab.example.com | 
> IllegalArgumentException |
> | *.example.com | `toASCII(s)` | *.example.com | *.example.com |
> | *.example.com | `toASCII(s, USE_STD3_ASCII_RULES)` | 
> IllegalArgumentException | IllegalArgumentException |
> | ab--cd.example.com | `toASCII(s)` | ab--cd.example.com | ab--cd.example.com 
> |
> | xn--fa-hia.de | `toUnicode(s)` | xn--fa-hia.de | faß.de |
> 
> `toUnicode()` still never throws. It returns any label it can't convert 
> unchanged, as before.
> 
> UTS46 considers labels with `--` in the third and fourth positions as errors. 
> `IDN` deliberately ignore...

If you don't have JBS access then you'll need a sponsor/buddy to help. First 
things first would be to try to get someone to help review what you propose.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/33210#issuecomment-6500594359

Reply via email to