commit e9c671d5e86e43785382ae9cb20c8e7676c7c9bf
parent fd62b36680ff7d7bea789ac0031a33fc2d9270ad
Author: Sergey M․ <dstftw@gmail.com>
Date:   Sat, 21 Jul 2018 12:30:18 +0700

[utils] Allow JSONP with empty func name (closes #17028)

Diffstat:
Mtest/test_utils.py | 4++++
Myoutube_dl/utils.py | 2+-
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/test/test_utils.py b/test/test_utils.py @@ -717,6 +717,10 @@ class TestUtil(unittest.TestCase): d = json.loads(stripped) self.assertEqual(d, {'status': 'success'}) + stripped = strip_jsonp('({"status": "success"});') + d = json.loads(stripped) + self.assertEqual(d, {'status': 'success'}) + def test_uppercase_escape(self): self.assertEqual(uppercase_escape('aä'), 'aä') self.assertEqual(uppercase_escape('\\U0001d550'), '𝕐') diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py @@ -2282,7 +2282,7 @@ def parse_age_limit(s): def strip_jsonp(code): return re.sub( r'''(?sx)^ - (?:window\.)?(?P<func_name>[a-zA-Z0-9_.$]+) + (?:window\.)?(?P<func_name>[a-zA-Z0-9_.$]*) (?:\s*&&\s*(?P=func_name))? \s*\(\s*(?P<callback_data>.*)\);? \s*?(?://[^\n]*)*$''',