Skip to content

Commit

Permalink
Don't check quotes when attributes are built from tokens.
Browse files Browse the repository at this point in the history
  • Loading branch information
earwig committed Oct 19, 2014
1 parent 32d8bc5 commit 810c24e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions mwparserfromhell/nodes/extras/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion mwparserfromhell/parser/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ def _handle_attribute(self, start):
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")
Expand Down

0 comments on commit 810c24e

Please sign in to comment.