Skip to content

validate host port - #3236

Merged
davidism merged 1 commit into
stablefrom
port
Aug 13, 2026
Merged

davidism merged 1 commit into
stablefrom
port

Conversation

@davidism

@davidism davidism commented Aug 13, 2026 •

Copy link
Copy Markdown
Member

host_is_trusted validates that 1 <= port <= 65535. 0 is a valid port, but not in the context of a host.

It also disallows leading zeros, for example 08443. I couldn't find a definitive spec for whether this was allowed or not. Firefox will navigate to https://example.com:08443, but rewrites it as 8443 when clicking the link or entering it in the address bar, and the dev tools shows the request without leading zeros. HTTPWG says nothing about leading zeros. WhatWG URL standard https://url.spec.whatwg.org/#port-state specifies that it is a 16-bit unsigned integer "0 to 65535 inclusive". So I've taken that to mean that leading zeros are not allowed in the port, but that clients might normalize them. That ensures there's not multiple representations of the same value, not sure if that would matter or not.

@davidism davidism added this to the 3.1.9 milestone Aug 13, 2026
@davidism
davidism merged commit a2bf38c into stable Aug 13, 2026
14 checks passed
@davidism
davidism deleted the port branch August 13, 2026 04:09
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant