{{ message }}
Repository navigation
Bracket IPv6 literals in Host headers and URLs - #8484
Open
RitiGrover wants to merge 2 commits into
Open
RitiGrover wants to merge 2 commits into
RitiGrover wants to merge 2 commits into
Conversation
This branch has not been deployed
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.

url.hostport()joined the host and port without brackets. For an IPv6 host that gives::1:8080which is ambiguous and not a valid Host value or URL authority.This showed up in a few places:
mitmdump --mode reverse:http://[::1]:8000rewrote theHostheader of every forwarded request to::1:8000.request.host,request.portorrequest.urlin a script rewrote theHostheader or:authoritythe same way.request.urlandrequest.pretty_urlreturnedhttp://::1:8080/afor IPv6 targets.hostport()now wraps an unbracketed IPv6 literal in brackets. A host that is already bracketed is left alone.unparse()useshostport()so it is fixed too.#8284 has the same change in
hostport(). That PR has had no review since June. This one also covers theRequesturl and Host header paths and the reverse proxy case with tests. I am happy to close this one if you would rather use #8284.Tests: five new tests across
test_url.py,test_http.pyandtest_modes.py(reverse proxy to[::1]:8000). They fail without the change. ruff and mypy pass. A broader run of the proxy, net, http and addon tests passes except for a few load dependent tests that fail the same way on unmodified main here.