Parcourir la source

compat_urllib_parse_unquote: crash fix: only decode valid hex

on python 2 the following has a { "crash_rate": "100%" } of the time
as it tries to parse '" ' as hex.
fnord il y a 10 ans
Parent
commit
e37c932fca
1 fichiers modifiés avec 2 ajouts et 0 suppressions
  1. 2 0
      youtube_dl/compat.py

+ 2 - 0
youtube_dl/compat.py

@@ -94,6 +94,8 @@ except ImportError:
             try:
                 if not item:
                     raise ValueError
+                if not re.match('[0-9a-fA-F][0-9a-fA-F]',item[:2]):
+                    raise ValueError
                 pct_sequence += item[:2].decode('hex')
                 rest = item[2:]
                 if not rest: