diff --git a/helpers/DATA/yt-dlp/patch_changes/002-make_cookies_parsing_more_lentient_on_python3.12.patch b/helpers/DATA/yt-dlp/patch_changes/002-make_cookies_parsing_more_lentient_on_python3.12.patch new file mode 100644 index 0000000..895c8f1 --- /dev/null +++ b/helpers/DATA/yt-dlp/patch_changes/002-make_cookies_parsing_more_lentient_on_python3.12.patch @@ -0,0 +1,35 @@ +diff --git a/yt_dlp/cookies.py b/yt_dlp/cookies.py +index 8c05a09f..8b6f6613 100644 +--- a/yt_dlp/cookies.py ++++ b/yt_dlp/cookies.py +@@ -1238,15 +1238,27 @@ def load(self, data): + else: + value, _ = self.value_decode(value) + +- morsel[key] = value ++ try: ++ morsel[key] = value ++ except http.cookies.CookieError: ++ # Lenient mode: ignore invalid attributes ++ pass + + elif is_attribute: + morsel = None + + elif value is not None: +- morsel = self.get(key, http.cookies.Morsel()) ++ morsel = self.get(key) or http.cookies.Morsel() + real_value, coded_value = self.value_decode(value) +- morsel.set(key, real_value, coded_value) ++ try: ++ morsel.set(key, real_value, coded_value) ++ except http.cookies.CookieError: ++ # Python 3.12+ rejects control characters in cookies. ++ # LenientSimpleCookie should accept them (yt-dlp tests expect this), so ++ # bypass Morsel.set() validation, assign underlying fields to read-only props. ++ morsel._key = key ++ morsel._value = real_value ++ morsel._coded_value = coded_value + self[key] = morsel + + else: