Skip to content

A feature-rich command-line audio/video downloader

compat_urllib_parse_unquote: crash fix: only decode valid hex

fnorde37c932fca29
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py
index c3783337a5..1f4ccf4432 100644
--- a/youtube_dl/compat.py
+++ b/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: