[utils] Add support for cookies with spaces used instead of tabs

This commit is contained in:
Sergey M․ 2020-03-08 17:52:19 +07:00
parent fa9b8c6628
commit cff99c91d1
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D
3 changed files with 19 additions and 5 deletions

View file

@ -2752,6 +2752,11 @@ class YoutubeDLCookieJar(compat_cookiejar.MozillaCookieJar):
for line in f:
if line.startswith(self._HTTPONLY_PREFIX):
line = line[len(self._HTTPONLY_PREFIX):]
# Cookie file may contain spaces instead of tabs.
# Replace all spaces with tabs to make such cookie files work
# with MozillaCookieJar.
if not line.startswith('#'):
line = re.sub(r' +', r'\t', line)
cf.write(compat_str(line))
cf.seek(0)
self._really_load(cf, filename, ignore_discard, ignore_expires)