From bab2e6711325f97080fd9ff0110ae8cb44b05cda Mon Sep 17 00:00:00 2001 From: rcombs Date: Fri, 3 May 2024 17:42:02 -0700 Subject: [PATCH] [cookies] Fix --cookies-from-browser=safari with unusual field order These fields can be specified in any order. `DataParser` doesn't support skipping backwards, so I make a temporary copy for each. --- yt_dlp/cookies.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/yt_dlp/cookies.py b/yt_dlp/cookies.py index 7b8d215f0..6f9e9cfed 100644 --- a/yt_dlp/cookies.py +++ b/yt_dlp/cookies.py @@ -645,14 +645,17 @@ def _parse_safari_cookies_record(data, jar, logger): _creation_date = _mac_absolute_time_to_posix(p.read_double()) # noqa: F841 try: - p.skip_to(domain_offset) - domain = p.read_cstring() + temp = DataParser(data, logger) + temp.skip_to(domain_offset) + domain = temp.read_cstring() - p.skip_to(name_offset) - name = p.read_cstring() + temp = DataParser(data, logger) + temp.skip_to(name_offset) + name = temp.read_cstring() - p.skip_to(path_offset) - path = p.read_cstring() + temp = DataParser(data, logger) + temp.skip_to(path_offset) + path = temp.read_cstring() p.skip_to(value_offset) value = p.read_cstring()