瀏覽代碼

[utils] Relax attribute key assert

Sergey M․ 10 年之前
父節點
當前提交
5d2354f177
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      youtube_dl/utils.py

+ 1 - 1
youtube_dl/utils.py

@@ -141,7 +141,7 @@ def write_json_file(obj, fn):
 if sys.version_info >= (2, 7):
 if sys.version_info >= (2, 7):
     def find_xpath_attr(node, xpath, key, val=None):
     def find_xpath_attr(node, xpath, key, val=None):
         """ Find the xpath xpath[@key=val] """
         """ Find the xpath xpath[@key=val] """
-        assert re.match(r'^[a-zA-Z-]+$', key)
+        assert re.match(r'^[a-zA-Z_-]+$', key)
         if val:
         if val:
             assert re.match(r'^[a-zA-Z0-9@\s:._-]*$', val)
             assert re.match(r'^[a-zA-Z0-9@\s:._-]*$', val)
         expr = xpath + ('[@%s]' % key if val is None else "[@%s='%s']" % (key, val))
         expr = xpath + ('[@%s]' % key if val is None else "[@%s='%s']" % (key, val))