Skip to content

Commit dadf711

Browse files
author
Mark Pilgrim
committed
added support for validating contenteditable attribute
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40974
1 parent e5cea2d commit dadf711

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/html5lib/filters/validator.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
_(u"'%(attributeName)s' attribute is not allowed on <input type=%(inputType)s>."),
3838
"deprecated-attribute":
3939
_(u"'%(attributeName)s' attribute is deprecated on <%(tagName)s>."),
40-
"invalid-class-attribute":
41-
_(u"Invalid class attribute value on <%(tagName)s>."),
4240
"duplicate-value-in-token-list":
4341
_(u"Duplicate value '%(attributeValue)s' in token list in '%(attributeName)s' attribute on <%(tagName)s>."),
42+
"invalid-attribute-value":
43+
_(u"Invalid value for '%(attributeName)s' attribute on <%(tagName)s>."),
4444
})
4545

4646
globalAttributes = frozenset(('class', 'contenteditable', 'contextmenu', 'dir',
@@ -317,8 +317,17 @@ def validateAttributeValueClass(self, token, tagName, attrName, attrValue):
317317
for t in self.checkTokenList(tagName, attrName, attrValue) or []:
318318
yield t
319319
yield {"type": "ParseError",
320-
"data": "invalid-class-attribute",
321-
"datavars": {"tagName": tagName}}
320+
"data": "invalid-attribute-value",
321+
"datavars": {"tagName": tagName,
322+
"attributeName": attrName}}
323+
324+
def validateAttributeValueContenteditable(self, token, tagName, attrName, attrValue):
325+
attrValue = attrValue.lower()
326+
if attrValue not in frozenset(('true', 'false', '')):
327+
yield {"type": "ParseError",
328+
"data": "invalid-attribute-value",
329+
"datavars": {"tagName": tagName,
330+
"attributeName": attrName}}
322331

323332
def checkTokenList(self, tagName, attrName, attrValue):
324333
# The "token" in the method name refers to tokens in an attribute value

0 commit comments

Comments
 (0)