瀏覽代碼

Don't check quotes when attributes are built from tokens.

tags/v0.4
Ben Kurtovic 10 年之前
父節點
當前提交
810c24e123
共有 2 個檔案被更改,包括 4 行新增3 行删除
  1. +2
    -2
      mwparserfromhell/nodes/extras/attribute.py
  2. +2
    -1
      mwparserfromhell/parser/builder.py

+ 2
- 2
mwparserfromhell/nodes/extras/attribute.py 查看文件

@@ -37,9 +37,9 @@ class Attribute(StringMixIn):
"""

def __init__(self, name, value=None, quotes='"', pad_first=" ",
pad_before_eq="", pad_after_eq=""):
pad_before_eq="", pad_after_eq="", check_quotes=True):
super(Attribute, self).__init__()
if not quotes and self._value_needs_quotes(value):
if check_quotes and not quotes and self._value_needs_quotes(value):
raise ValueError("given value {0!r} requires quotes".format(value))
self._name = name
self._value = value


+ 2
- 1
mwparserfromhell/parser/builder.py 查看文件

@@ -237,7 +237,8 @@ class Builder(object):
else:
name, value = self._pop(), None
return Attribute(name, value, quotes, start.pad_first,
start.pad_before_eq, start.pad_after_eq)
start.pad_before_eq, start.pad_after_eq,
check_quotes=False)
else:
self._write(self._handle_token(token))
raise ParserError("_handle_attribute() missed a close token")


Loading…
取消
儲存