[utils] Allow JSONP with empty func name (closes #17028)
authorSergey M․ <dstftw@gmail.com>
Sat, 21 Jul 2018 05:30:18 +0000 (12:30 +0700)
committerSergey M․ <dstftw@gmail.com>
Sat, 21 Jul 2018 05:30:18 +0000 (12:30 +0700)
test/test_utils.py
youtube_dl/utils.py

index e63af01668ceb84cc2d8452490bc94eb48791f40..de841b1a07c618aa1c3c79e6602f87fed8d9c997 100644 (file)
@@ -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'), '𝕐')
index 8c45166d76cd1d9150e67ba26f80ce61cb8c275c..b8700efcbd6860c74e5a96b5ed7790aaa26fbd94 100644 (file)
@@ -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]*)*$''',