From 7d4111ed14848c3e72d55d47f11cd7e9fadea403 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Sun, 23 Nov 2014 10:49:19 +0100 Subject: Provide guidance when called with a YouTube ID starting with a dash. Reported at https://news.ycombinator.com/item?id=8648121 --- youtube_dl/compat.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'youtube_dl/compat.py') 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): -- cgit v1.2.3