Repository navigation
Conversation
|
The split-once fix preserves |
Mansi2221
left a comment
There was a problem hiding this comment.
One-character fix with real impact. RFC 8288 allows parameter values to contain = (especially when quoted), and param.split("=") with no limit raised ValueError on title="a=b" and triggered the except ValueError: break which silently dropped all remaining parameters on that link — including rel, which the Response.links dict uses as the key.
So a Link: </page/2>; title="a=b"; rel="next" header previously disappeared entirely from response.links. The maxsplit=1 correctly splits only on the first =.
Test covers the exact scenario. Could also add a case where the value contains multiple = (e.g. base64-encoded token in a state= param), but the single-= case is representative.
LGTM.
Summary
In
httpx._models._parse_header_links(), splitting link parameters withparam.split("=")raisesValueErrorwhen a parameter value itself contains=(e.g.Link: </page/2>; title="a=b"; rel="next"). Because the surroundingexcept ValueError: breakaborts parsing that link, both the parameter and any subsequent parameters such asrel="next"are silently dropped.This PR changes the split to
param.split("=", 1)and adds a regression test intests/models/test_headers.py.Verification
pytest -q tests/models/test_headers.py: 28 passed