Skip to content

Reject URI hosts with non-ASCII data - #939

Merged
GrahamCampbell merged 1 commit into
4.0from
reject-uri-hosts-with-non-ascii-data-4.0
Nov 22, 2026
Merged

GrahamCampbell merged 1 commit into
4.0from
reject-uri-hosts-with-non-ascii-data-4.0

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Member

The host is the one URI component that Uri passes 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 reaches new Uri(), Uri::withHost(), Uri::fromParts(), a Host header derived from another UriInterface implementation, Message::parseRequest() and Message::parseRequestUri(), and ServerRequest::fromGlobals() falls back to SERVER_NAME as it does for any malformed HTTP_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, with Idna::uriFor() or Idna::toAscii(). Closes #643.

@GrahamCampbell
GrahamCampbell force-pushed the reject-uri-hosts-with-non-ascii-data-4.0 branch 2 times, most recently from 3d7e555 to aad2a63 Compare November 22, 2026 01:02
@GrahamCampbell
GrahamCampbell force-pushed the reject-uri-hosts-with-non-ascii-data-4.0 branch from aad2a63 to 00d4383 Compare November 22, 2026 01:17
@GrahamCampbell
GrahamCampbell marked this pull request as ready for review November 22, 2026 02:42
@GrahamCampbell
GrahamCampbell merged commit f76c904 into 4.0 Nov 22, 2026
36 checks passed
@GrahamCampbell
GrahamCampbell deleted the reject-uri-hosts-with-non-ascii-data-4.0 branch November 22, 2026 02:43
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.

1 participant