Browse Source

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

master-ytdl-org
Sergey M․ 7 years ago
parent
commit
e9c671d5e8
No known key found for this signature in database GPG Key ID: 2C393E0F18A9236D
2 changed files with 5 additions and 1 deletions
  1. +4
    -0
      test/test_utils.py
  2. +1
    -1
      youtube_dl/utils.py

+ 4
- 0
test/test_utils.py View 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(''), '')
self.assertEqual(uppercase_escape('\\U0001d550'), '𝕐')


+ 1
- 1
youtube_dl/utils.py View 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]*)*$''',


Loading…
Cancel
Save