Skip to content

Commit 028edad

Browse files
committed
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.
1 parent d64b9ad commit 028edad

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/requests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ def parse_header_links(value: str) -> list[dict[str, str]]:
988988

989989
for param in params.split(";"):
990990
try:
991-
key, value = param.split("=")
991+
key, value = param.split("=", 1)
992992
except ValueError:
993993
break
994994

tests/test_utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,12 @@ def test_iter_slices(value, length):
690690
{"url": "http://.../back.jpeg"},
691691
],
692692
),
693+
(
694+
# A quoted parameter value may itself contain "=" (RFC 8288);
695+
# it must be kept and must not drop the parameters after it.
696+
'<http:/.../front.jpeg>; title="a=b"; rel="next"',
697+
[{"url": "http:/.../front.jpeg", "title": "a=b", "rel": "next"}],
698+
),
693699
("", []),
694700
),
695701
)

0 commit comments

Comments
 (0)