[staging] Host header field contains scope of IPv6 link-local address - #1
Draft
loonister1 wants to merge 4 commits into
Draft
[staging] Host header field contains scope of IPv6 link-local address#1loonister1 wants to merge 4 commits into
loonister1 wants to merge 4 commits into
Conversation
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.
Staging review — this PR targets your own fork. Upstream sees nothing until you approve.
Commits
d1af479eStrip IPv6 zone identifier from the Host header — 1 file(s), 5 linescfdf3afbAdd tests for IPv6 zone identifiers in the Host header — 1 file(s), 15 lines5ce910bfAdd changelog entry for the IPv6 zone identifier fix — 1 file(s), 3 lines44d40027Add Shahzaib Niaz to CONTRIBUTORS.txt — 1 file(s), 1 linesWhat this change does
ClientRequestBase._update_headersnow removes an IPv6 zone identifier from the value derived fromURL.host_port_subcomponentbefore it becomes theHostheader, per RFC 6874 §4, while leavingraw_host— and therefore connection keying and DNS/socket resolution — untouched so link-local addresses remain reachable. The strip is gated on the host being a bracketed IP-literal, so percent-encoded octets in ordinary reg-names are unaffected, and an explicitly suppliedHostheader still passes through verbatim as it does for the existing trailing-dot handling.Reviewer notes
verdict=merge
reason=The patch strips the ZoneID at exactly the point where the Host header value is derived (
host_port_subcomponent), leavesraw_host/connection keying alone so link-local targets stay reachable, and is covered by a behavioural test in the file's existing parametrize style alongsidetest_host_header_ipv6_with_port; changelog fragment and CONTRIBUTORS entry follow project convention (alphabetical placement is correct).risk=1) Scope of RFC 6874 §4: the strip covers only the Host header. A request through a plain HTTP proxy uses absolute-form in the request line, and a CONNECT request builds its target from
url.host_subcomponent— both still carry%zone. That is arguably the same MUST, and it is the maintainers' call whether to widen this PR, factor the strip into a helper both paths use, or push it upstream into yarl (which is where ahost_port_subcomponentthat already claims RFC-3986 conformance could reasonably do it). I would not block on it, but ask the contributor to say explicitly that they know it is deferred. 2) The slicinghost[:index('%')] + host[index(']'):]is robust to both%eth0and%25eth0because]always follows%in a bracketed literal — but whether yarl hands back the decoded or percent-encoded zone varies by how yarl normalises the netloc, so confirm the test passes against aiohttp's minimum pinned yarl, not just the 1.24.5 the reporter used. If yarl ever returns a host without a closing bracket,.index(']')raises ValueError rather than degrading; apartition-based form would avoid that and drop the double scan. 3) Hot path:_update_headersruns on every request; two extra string ops is small, but bdraco has previously reworked checks here for cost, so expect a nit towardhost[0] == '['or folding into one pass. 4) Untested claims from the summary: an explicitly suppliedHostcontaining a zone id passing through verbatim, and a percent-containing reg-name being untouched — both look right from the code, neither has a test. 5) Cosmetic: the changelog credits:user:loonister1`` while CONTRIBUTORS.txt adds "Shahzaib Niaz"; normal (handle vs. real name) but worth a glance that both are the same person.concerns=- Tests were not executed. Python execution is blocked in this session, so nothing was run — not the new test, not the surrounding
test_client_request.py, not black/mypy. Please run `PYTHONPATH=. pytest tests/test_client_request.py` and `pre-commit run --all-files` before this goes anywhere. The formatting was hand-matched to black's slice style already used at `aiohttp/http_parser.py:1018`.client_reqrep.py:945-947) and the absolute-form target sent to a non-SSL proxy (client_reqrep.py:949,str(self.url)). Both are proxy-only paths and neither is what the issue reports, so I left them; if maintainers want them covered it is a natural follow-up rather than a widening of this patch.:user:loonister1``, inferred from the git author's noreply address. Worth confirming that is the intended handle.attempts=1
Test output
Lint
To act on this, add a label:
contrib:submitto open it upstream ·contrib:rejectto discard ·contrib:holdto leave it queued.