AI junk#6094
Closed
abhi-0203 wants to merge 1 commit into
Closed
Conversation
Two places used .partition(":") to split host:port, which breaks
for IPv6 addresses like [::1]:8000 because the colon inside the
bracket notation is not the host:port separator.
- testing.py: Extract hostname from host header using bracket-aware parsing
- app.py: Parse SERVER_NAME config with bracket-aware host:port splitting
Fixes #6093
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.
Description
Fixes incorrect host parsing for IPv6 addresses in two locations.
Problem
Two places used
.partition(":")to split host:port, which breaks for IPv6 addresses like[::1]:8000because the colon inside the bracket notation is not the host:port separator.ctx.request.host.partition(":")[0]returns[::1instead of::1for IPv6 host headersserver_name.partition(":")returns[::1as host and8000]as port for IPv6 SERVER_NAMEFix
[, extract hostname between brackets; otherwise use existing partition logic[, find the]bracket and parse port after it; otherwise use existing partition logicTesting
Added comprehensive test cases covering:
127.0.0.1:8000[::1]:8000localhost[::1][2001:db8::1]:8080All tests pass.
Closes #6093