Skip to content

Commit

Permalink
Revert "[utils] Add support for cookies with spaces used instead of t…
Browse files Browse the repository at this point in the history
…abs"

According to [1] TABs must be used as separators between fields.
Files produces by some tools with spaces as separators are considered
malformed.

1. https://curl.haxx.se/docs/http-cookies.html

This reverts commit cff99c9.
  • Loading branch information
dstftw committed Mar 9, 2020
1 parent 68fa151 commit 042b664
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
14 changes: 5 additions & 9 deletions test/test_YoutubeDLCookieJar.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@


class TestYoutubeDLCookieJar(unittest.TestCase):
def __assert_cookie_has_value(self, cookiejar, key):
self.assertEqual(cookiejar._cookies['www.foobar.foobar']['/'][key].value, key + '_VALUE')

def test_keep_session_cookies(self):
cookiejar = YoutubeDLCookieJar('./test/testdata/cookies/session_cookies.txt')
cookiejar.load(ignore_discard=True, ignore_expires=True)
Expand All @@ -35,13 +32,12 @@ def test_keep_session_cookies(self):
def test_strip_httponly_prefix(self):
cookiejar = YoutubeDLCookieJar('./test/testdata/cookies/httponly_cookies.txt')
cookiejar.load(ignore_discard=True, ignore_expires=True)
self.__assert_cookie_has_value(cookiejar, 'HTTPONLY_COOKIE')
self.__assert_cookie_has_value(cookiejar, 'JS_ACCESSIBLE_COOKIE')

def test_convert_spaces_to_tabs(self):
cookiejar = YoutubeDLCookieJar('./test/testdata/cookies/cookie_file_with_spaces.txt')
cookiejar.load(ignore_discard=True, ignore_expires=True)
self.__assert_cookie_has_value(cookiejar, 'COOKIE')
def assert_cookie_has_value(key):
self.assertEqual(cookiejar._cookies['www.foobar.foobar']['/'][key].value, key + '_VALUE')

assert_cookie_has_value('HTTPONLY_COOKIE')
assert_cookie_has_value('JS_ACCESSIBLE_COOKIE')


if __name__ == '__main__':
Expand Down
5 changes: 0 additions & 5 deletions test/testdata/cookies/cookie_file_with_spaces.txt

This file was deleted.

5 changes: 0 additions & 5 deletions youtube_dl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2752,11 +2752,6 @@ def load(self, filename=None, ignore_discard=False, ignore_expires=False):
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)
Expand Down

0 comments on commit 042b664

Please sign in to comment.