YoutubeDL: format spec: don't accept a bare '/' (#6124)
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Mon, 3 Aug 2015 21:04:11 +0000 (23:04 +0200)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Mon, 3 Aug 2015 21:04:11 +0000 (23:04 +0200)
test/test_YoutubeDL.py
youtube_dl/YoutubeDL.py

index 20f45f439748723998ce690cf54da55bfff34d29..9a3c28f8c101ff99cdc18504974bf1f69c29c410 100644 (file)
@@ -311,6 +311,7 @@ class TestFormatSelection(unittest.TestCase):
         assert_syntax_error('bestvideo,,best')
         assert_syntax_error('+bestaudio')
         assert_syntax_error('bestvideo+')
+        assert_syntax_error('/')
 
     def test_format_filtering(self):
         formats = [
index efa3254ceec68d1a9af9d82cb146be63ffbe9309..c608ff91a91636bc40b4fa1c99c013aadcc80820 100755 (executable)
@@ -960,6 +960,8 @@ class YoutubeDL(object):
                         selectors.append(current_selector)
                         current_selector = None
                     elif string == '/':
+                        if not current_selector:
+                            raise syntax_error('"/" must follow a format selector', start)
                         first_choice = current_selector
                         second_choice = _parse_format_selection(tokens, inside_choice=True)
                         current_selector = FormatSelector(PICKFIRST, (first_choice, second_choice), [])