Skip to content

Commit d941579

Browse files
committed
fix: never run IDN canonicalization on bracketed IP literals
A bracketed host with a malformed zone identifier (e.g. [fe80::1%25]) is not an IP per parse, so canonicalizeHost fell through to the WHATWG fallback. Node >= 18 throws there (fail-closed), but Node 16's URL parser accepts the input and .hostname strips the brackets, truncating the malformed literal. Skip hosts starting with '[' — IDN conversion only applies to reg-names.
1 parent c0f0279 commit d941579

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ function canonicalizeHost (parsed, options, schemeHandler, isIP) {
351351
!options.unicodeSupport &&
352352
(!schemeHandler || !schemeHandler.unicodeSupport) &&
353353
parsed.host &&
354+
parsed.host[0] !== '[' &&
354355
(options.domainHost || (schemeHandler && schemeHandler.domainHost)) &&
355356
isIP === false &&
356357
nonSimpleDomain(parsed.host)

0 commit comments

Comments
 (0)