Skip to content

validate host characters - #3113

Merged
davidism merged 1 commit into
mainfrom
host-chars
Feb 24, 2026
Merged

davidism merged 1 commit into
mainfrom
host-chars

Conversation

@davidism

Copy link
Copy Markdown
Member

Request.host, get_host, and host_is_trusted validate the characters of the host value. They do not validate the value, only that its characters could form a valid host. The empty string is no longer allowed, the host value must contain characters.

The trusted_list argument to host_is_trusted is optional to make it easier to use to validate the characters only, if trusted hosts aren't configured.

If no Host header is present, these would fall back to using the server's configured address (host, port). When listening on a unix socket, this would end up like ("/path/to/socket", None), which is not valid as a host value. A unix socket address is now ignored, as it would not produce a useful value when used by other functions such as URL building anyway.

Rewrite the docs for these.

@davidism davidism added this to the 3.2.0 milestone Feb 24, 2026
@davidism
davidism merged commit ac25626 into main Feb 24, 2026
12 checks passed
@davidism
davidism deleted the host-chars branch February 24, 2026 03:23
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 11, 2026
@davidism

Copy link
Copy Markdown
Member Author

cherry picked to stable d3d3df5

@davidism davidism modified the milestones: 3.2.0, 3.1.7 Mar 23, 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