[utils] Allow dot in strip_jsonp
authorSergey M․ <dstftw@gmail.com>
Sun, 7 Feb 2016 13:47:09 +0000 (19:47 +0600)
committerSergey M․ <dstftw@gmail.com>
Sun, 7 Feb 2016 13:47:09 +0000 (19:47 +0600)
test/test_utils.py
youtube_dl/utils.py

index 909d0e51d7d4594e85522fa48f00ae9cba66b19b..a1e416dd5fdd1e385a5a37e87b65e3d78e334b4a 100644 (file)
@@ -494,6 +494,10 @@ class TestUtil(unittest.TestCase):
         d = json.loads(stripped)
         self.assertEqual(d, {'STATUS': 'OK'})
 
+        stripped = strip_jsonp('ps.embedHandler({"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 f3b0180abb050173099e03ccde81c8412898e19f..dce67de8ac323441926aa1337153e193b88f8c0a 100644 (file)
@@ -1749,7 +1749,7 @@ def parse_age_limit(s):
 
 def strip_jsonp(code):
     return re.sub(
-        r'(?s)^[a-zA-Z0-9_]+\s*\(\s*(.*)\);?\s*?(?://[^\n]*)*$', r'\1', code)
+        r'(?s)^[a-zA-Z0-9_.]+\s*\(\s*(.*)\);?\s*?(?://[^\n]*)*$', r'\1', code)
 
 
 def js_to_json(code):