parse_header_links drops parameters when a value contains '=' or a quoted ';'
Summary
requests.utils.parse_header_links silently drops Link header parameters in two cases.
1. Parameter value containing =
In src/requests/utils.py, key, value = param.split("=") raises ValueError when the value contains =. The except ValueError: break then discards every remaining parameter.
2. ; inside a quoted value
params.split(";") ignores quoting, so a quoted value containing ; is truncated and the rest is lost.
Repro
from requests.utils import parse_header_links as p
p('<https://a/b>; rel="next"; title="x=y"; type="t"')
# actual: [{'url': 'https://a/b', 'rel': 'next'}] # title and type missing
# expected: [{'url': 'https://a/b', 'rel': 'next', 'title': 'x=y', 'type': 't'}]
p('<https://a/b>; title="a;b"; rel=next')
# actual: [{'url': 'https://a/b', 'title': 'a'}] # rel missing, title truncated
# expected: [{'url': 'https://a/b', 'title': 'a;b', 'rel': 'next'}]
Suggested fix
Use param.split("=", 1) and split parameters in a quote-aware way. I'm happy to open a PR with tests if this is welcome.
Checked on current main. I searched existing issues (#2250, #2707, #7177 are related to other cases) and found none covering this.
I confirmed both regressions locally and have a fix ready on my fork:
Branch: https://github.com/Lushiyao5/requests/tree/fix/parse-header-links-params-20261108
Changes (commit e7fef6e7, based on current main):
- Split each parameter only on the first
=(split("=", 1)), so a value containing=no longer raisesValueErrorand drops the remaining parameters. - Split the parameter list with a small quote-aware helper (
_split_header_params) that keeps semicolons inside double-quoted values intact.
Both cases from this issue are covered by new parametrized cases in tests/test_utils.py::test_parse_header_links — they fail on current main and pass with the fix (tests/test_utils.py: 230 passed). Happy to open a PR if you'd like; PR creation is currently limited to collaborators for this repository (the compare page shows the banner and the API returns 404/FORBIDDEN), so I'm leaving the branch here for you or the reporter to cherry-pick or open from.