Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ext/node): Match punycode module behavior to node #22847

Merged
merged 7 commits into from Mar 11, 2024

Conversation

nathanwhit
Copy link
Member

Fixes #19214.

We were using the idna crate to implement our polyfill for punycode.toASCII and punycode.toUnicode. The idna crate is correct, and adheres to the IDNA2003/2008 spec, but it turns out node's implementations don't really follow any spec! Instead, node splits the domain by '.' and punycode encodes/decodes each part. This means that node's implementations will happily work on codepoints that are disallowed by the IDNA specs, causing the error in #19214.

While fixing this, I went ahead and matched the node behavior on all of the punycode functions and enabled node's punycode test in our node_compat suite.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, nice fix!

@nathanwhit nathanwhit merged commit a77b298 into denoland:main Mar 11, 2024
17 checks passed
@nathanwhit nathanwhit deleted the punycode-weirdness branch March 11, 2024 22:49
nathanwhit added a commit that referenced this pull request Mar 14, 2024
Fixes #19214.

We were using the `idna` crate to implement our polyfill for
`punycode.toASCII` and `punycode.toUnicode`. The `idna` crate is
correct, and adheres to the IDNA2003/2008 spec, but it turns out
`node`'s implementations don't really follow any spec! Instead, node
splits the domain by `'.'` and punycode encodes/decodes each part. This
means that node's implementations will happily work on codepoints that
are disallowed by the IDNA specs, causing the error in #19214.

While fixing this, I went ahead and matched the node behavior on all of
the punycode functions and enabled node's punycode test in our
`node_compat` suite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

个��.hk throws error at Object.toASCII (ext:deno_node/punycode.ts:5:16)
2 participants