From 028edad469bae290e643e027439286c67719f0c9 Mon Sep 17 00:00:00 2001 From: nyxst4ck <289980115+nyxst4ck@users.noreply.github.com> Date: Tue, 16 Jun 2026 18:44:11 -0300 Subject: [PATCH] Keep Link header parameter values that contain '=' parse_header_links split each parameter on '=' without a maxsplit, so a quoted value containing '=' (allowed by RFC 8288) produced 3+ parts and raised ValueError. The bare 'except ValueError: break' then silently dropped that parameter and every parameter after it in the link. Use split('=', 1) so the value keeps its '=' and later parameters survive. --- src/requests/utils.py | 2 +- tests/test_utils.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/requests/utils.py b/src/requests/utils.py index fff6edf4be..4439dfe989 100644 --- a/src/requests/utils.py +++ b/src/requests/utils.py @@ -988,7 +988,7 @@ def parse_header_links(value: str) -> list[dict[str, str]]: for param in params.split(";"): try: - key, value = param.split("=") + key, value = param.split("=", 1) except ValueError: break diff --git a/tests/test_utils.py b/tests/test_utils.py index 091a9fd6f3..9bc5843f02 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -690,6 +690,12 @@ def test_iter_slices(value, length): {"url": "http://.../back.jpeg"}, ], ), + ( + # A quoted parameter value may itself contain "=" (RFC 8288); + # it must be kept and must not drop the parameters after it. + '; title="a=b"; rel="next"', + [{"url": "http:/.../front.jpeg", "title": "a=b", "rel": "next"}], + ), ("", []), ), )