[whatwg/url] More IDNA roundtrippability issues (Issue #760)

Here are a few more issues (from @valenting in https://github.com/whatwg/url/issues/603#issuecomment-1462034815). We need to sort out whose fault this is: the spec or the whatwg-url implementation. (I've also included a few additional examples to defeat ASCII-only fast path in Chrome.)

| input | whatwg-url | Chrome | WebKit | Live URL Viewer |
| --- | -- | -- | -- | -- |
| http://a.xn--xn-----/ | http://a.xn----/ | http://a.xn--xn-----/ | error | [link](https://jsdom.github.io/whatwg-url/#url=aHR0cDovL2EueG4tLXhuLS0tLS0v&base=YWJvdXQ6Ymxhbms=) |
| http://é.xn--xn-----/ | http://xn--9ca.xn----/ | error | error | [link](https://jsdom.github.io/whatwg-url/#url=aHR0cDovL8OpLnhuLS14bi0tLS0tLw==&base=YWJvdXQ6Ymxhbms=) |
| http://a.xn----/ | http://a.-/ | http://a.xn----/ | error | [link](https://jsdom.github.io/whatwg-url/#url=aHR0cDovL2EueG4tLS0tLw==&base=YWJvdXQ6Ymxhbms=) |
| http://é.xn----/ | http://xn--9ca.-/ | error | error | [link](https://jsdom.github.io/whatwg-url/#url=aHR0cDovL8OpLnhuLS0tLS8=&base=YWJvdXQ6Ymxhbms=) |
| http://a.xn--/ | http://a./ | http://a.xn----/ | error | [link](https://jsdom.github.io/whatwg-url/#url=aHR0cDovL2EueG4tLS8=&base=YWJvdXQ6Ymxhbms=) |
| http://é.xn--/ | http://xn--9ca./ | error | error | [link](https://jsdom.github.io/whatwg-url/#url=aHR0cDovL8OpLnhuLS0v&base=YWJvdXQ6Ymxhbms=) |

----

Without digging too deep, it seems like Punycode-decoding all of these labels result in an all-ASCII label, that should never have been Punycode-encoded in the first place. However, RFC 3492 says the following:

> Using hyphen-minus as the delimiter implies that the encoded string can end with a hyphen-minus only if the Unicode string consists entirely of basic code points, **but IDNA forbids such strings from being encoded.**

I'm not yet sure where in IDNA this requirement is set, but if Unicode IDNA included this requirement then that'd probably solve this issue.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/760
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/issues/760@github.com>

Received on Thursday, 9 March 2023 19:27:42 UTC