[utils] Skip invalid/non HTML entities (Closes #7518)
authorSergey M․ <dstftw@gmail.com>
Mon, 16 Nov 2015 14:20:16 +0000 (20:20 +0600)
committerSergey M․ <dstftw@gmail.com>
Mon, 16 Nov 2015 14:20:16 +0000 (20:20 +0600)
test/test_utils.py
youtube_dl/utils.py

index 01829f71e3b89148b06d6b0fe2eba6d15d6b5dfb..ea1ff0547cbb1e9dd081fb6b90243c0269d7d9ef 100644 (file)
@@ -210,8 +210,8 @@ class TestUtil(unittest.TestCase):
         self.assertEqual(unescapeHTML('%20;'), '%20;')
         self.assertEqual(unescapeHTML('&#x2F;'), '/')
         self.assertEqual(unescapeHTML('&#47;'), '/')
-        self.assertEqual(
-            unescapeHTML('&eacute;'), 'é')
+        self.assertEqual(unescapeHTML('&eacute;'), 'é')
+        self.assertEqual(unescapeHTML('&#2013266066;'), '&#2013266066;')
 
     def test_daterange(self):
         _20century = DateRange("19000101", "20000101")
index d39f313a41802f38f91418e12cc89dcd798b0286..b7013a6aaef400633d45ac33c4a7fcb949802be7 100644 (file)
@@ -396,7 +396,11 @@ def _htmlentity_transform(entity):
             numstr = '0%s' % numstr
         else:
             base = 10
-        return compat_chr(int(numstr, base))
+        # See https://github.com/rg3/youtube-dl/issues/7518
+        try:
+            return compat_chr(int(numstr, base))
+        except ValueError:
+            pass
 
     # Unknown entity in name, return its literal representation
     return ('&%s;' % entity)