Repository navigation
Reject URI hosts with non-ASCII data - #939
Merged
Merged
Conversation
GrahamCampbell
force-pushed
the
reject-uri-hosts-with-non-ascii-data-4.0
branch
2 times, most recently
from
November 22, 2026 01:02
3d7e555 to
aad2a63
Compare
GrahamCampbell
force-pushed
the
reject-uri-hosts-with-non-ascii-data-4.0
branch
from
November 22, 2026 01:17
aad2a63 to
00d4383
Compare
GrahamCampbell
marked this pull request as ready for review
November 22, 2026 02:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The host is the one URI component that
Uripasses through with non-ASCII data intact, so a URI can serialize to a string that is not an RFC 3986 URI and name a host that a transport maps onto a different one. #643 decided that 4.0 requires URI hosts to be ASCII, and 3.6 deprecated the others.Rfc3986::isValidHost()now rejects bytes from 0x80 upward, and its existing rule that a percent-encoded octet is invalid when the byte it decodes to is invalid extends that to percent-encoded non-ASCII octets. The rule reachesnew Uri(),Uri::withHost(),Uri::fromParts(), aHostheader derived from anotherUriInterfaceimplementation,Message::parseRequest()andMessage::parseRequestUri(), andServerRequest::fromGlobals()falls back toSERVER_NAMEas it does for any malformedHTTP_HOST. Hosts that remain valid are spelled exactly as before, so nothing is re-encoded. An internationalized domain name must be converted to A-labels first, withIdna::uriFor()orIdna::toAscii(). Closes #643.