浏览代码

YoutubeDL: format spec: don't accept a bare '/' (#6124)

Jaime Marquínez Ferrándiz 10 年之前
父节点
当前提交
d96d604e53
共有 2 个文件被更改,包括 3 次插入0 次删除
  1. 1 0
      test/test_YoutubeDL.py
  2. 2 0
      youtube_dl/YoutubeDL.py

+ 1 - 0
test/test_YoutubeDL.py

@@ -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 = [

+ 2 - 0
youtube_dl/YoutubeDL.py

@@ -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), [])