aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/compat.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-11-23 10:49:19 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2014-11-23 10:51:09 +0100
commit7d4111ed14848c3e72d55d47f11cd7e9fadea403 (patch)
treefd583582ca5caf291a12a18a9f9cb3fc61b1b1f8 /youtube_dl/compat.py
parentd37cab2a9d1da8056460613007f3099e7a9d8f7e (diff)
Provide guidance when called with a YouTube ID starting with a dash.
Reported at https://news.ycombinator.com/item?id=8648121
Diffstat (limited to 'youtube_dl/compat.py')
-rw-r--r--youtube_dl/compat.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py
index 9d33a8ec5..549206534 100644
--- a/youtube_dl/compat.py
+++ b/youtube_dl/compat.py
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
import getpass
import optparse
import os
+import re
import subprocess
import sys
@@ -174,7 +175,10 @@ try:
from shlex import quote as shlex_quote
except ImportError: # Python < 3.3
def shlex_quote(s):
- return "'" + s.replace("'", "'\"'\"'") + "'"
+ if re.match(r'^[-_\w./]+$', s):
+ return s
+ else:
+ return "'" + s.replace("'", "'\"'\"'") + "'"
def compat_ord(c):