Skip to content

fix(node:url): WHATWG IPv4 host canonicalization (hostname setter + domainToASCII) (#3056, #3059)#3529

Merged
proggeramlug merged 2 commits into
mainfrom
fix-url-host-canon-3056-3059
May 31, 2026
Merged

fix(node:url): WHATWG IPv4 host canonicalization (hostname setter + domainToASCII) (#3056, #3059)#3529
proggeramlug merged 2 commits into
mainfrom
fix-url-host-canon-3056-3059

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Closes #3056
Closes #3059

Adds whatwg_canonicalize_host (reparses http://<host>/ via the url crate) so numeric/IPv4-shorthand hosts canonicalize per WHATWG (u.hostname=1230.0.0.123; url.domainToASCII(123)0.0.0.123) while ordinary hostnames and punycode IDN labels are unchanged. Gap test + existing URL parity tests byte-identical to Node. Verified under default auto-optimize compile.

Ralph Küpper added 2 commits May 31, 2026 07:14
…+ domainToASCII

Perry's URL uses a custom hostname parser that only runs IDNA, so it
never applied the WHATWG numeric/IPv4-shorthand host parser. Borrow the
url crate's WHATWG host parser as a post-step:

- hostname setter (#3056): Web-IDL-stringify the RHS then canonicalize
  (123 -> 0.0.0.123, 0x7f.1 -> 127.0.0.1); out-of-range numeric leaves
  the host unchanged, matching Node.
- domainToASCII/domainToUnicode (#3059): stringify the arg and run the
  same WHATWG host parsing (numeric -> IPv4, IDN -> punycode/Unicode,
  invalid -> '').

Ordinary + IDN hostnames are unchanged.
…56-3059

# Conflicts:
#	crates/perry-codegen/src/expr/url_main.rs
#	crates/perry-runtime/src/url/mod.rs
@proggeramlug proggeramlug merged commit ba1c7eb into main May 31, 2026
11 checks passed
@proggeramlug proggeramlug deleted the fix-url-host-canon-3056-3059 branch May 31, 2026 05:44
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.

node:url: coerce domainToASCII and domainToUnicode inputs node:url: coerce URL property setter values to strings

1 participant