mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-02-20 15:35:44 +00:00
[cookies] Ignore cookies with control characters (#15862)
http.cookies.Morsel was patched in Python 3.14.3 and 3.13.12 to raise a CookieError if the cookie name, value or any attribute of its input contains a control character. yt_dlp.cookies.LenientSimpleCookie now preemptively discards any cookies containing control characters, which is consistent with its more lenient parsing. Ref: https://github.com/python/cpython/issues/143919 Closes #15849 Authored by: bashonly, syphyr Co-authored-by: syphyr <syphyr@gmail.com>
This commit is contained in:
@@ -205,8 +205,8 @@ class TestLenientSimpleCookie(unittest.TestCase):
|
||||
),
|
||||
(
|
||||
'Test quoted cookie',
|
||||
'keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"',
|
||||
{'keebler': 'E=mc2; L="Loves"; fudge=\012;'},
|
||||
'keebler="E=mc2; L=\\"Loves\\"; fudge=;"',
|
||||
{'keebler': 'E=mc2; L="Loves"; fudge=;'},
|
||||
),
|
||||
(
|
||||
"Allow '=' in an unquoted value",
|
||||
@@ -328,4 +328,30 @@ class TestLenientSimpleCookie(unittest.TestCase):
|
||||
'Key=Value; [Invalid]=Value; Another=Value',
|
||||
{'Key': 'Value', 'Another': 'Value'},
|
||||
),
|
||||
# Ref: https://github.com/python/cpython/issues/143919
|
||||
(
|
||||
'Test invalid cookie name w/ control character',
|
||||
'foo\012=bar;',
|
||||
{},
|
||||
),
|
||||
(
|
||||
'Test invalid cookie name w/ control character 2',
|
||||
'foo\015baz=bar',
|
||||
{},
|
||||
),
|
||||
(
|
||||
'Test invalid cookie name w/ control character followed by valid cookie',
|
||||
'foo\015=bar; x=y;',
|
||||
{'x': 'y'},
|
||||
),
|
||||
(
|
||||
'Test invalid cookie value w/ control character',
|
||||
'keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"',
|
||||
{},
|
||||
),
|
||||
(
|
||||
'Test invalid quoted attribute value w/ control character',
|
||||
'Customer="WILE_E_COYOTE"; Version="1\\012"; Path="/acme"',
|
||||
{},
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user