Skip to content

Commit d11eff2

Browse files
author
Mark Pilgrim
committed
added support for validating <html xmlns> attribute
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40985
1 parent d559d9e commit d11eff2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/html5lib/filters/validator.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
_(u"Invalid language code: '%(attributeName)s' attibute on <%(tagName)s>."),
6161
"invalid-integer-value":
6262
_(u"Value must be an integer: '%(attributeName)s' attribute on <%tagName)s>."),
63+
"invalid-root-namespace":
64+
_(u"Root namespace must be 'http://www.w3.org/1999/xhtml', or omitted."),
6365
})
6466

6567
globalAttributes = frozenset(('class', 'contenteditable', 'contextmenu', 'dir',
@@ -71,6 +73,7 @@
7173
'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup',
7274
'onmousewheel', 'onresize', 'onscroll', 'onselect', 'onsubmit', 'onunload'))
7375
# XXX lang in HTML only, xml:lang in XHTML only
76+
# XXX validate ref, template
7477

7578
allowedAttributeMap = {
7679
'html': frozenset(('xmlns',)),
@@ -399,6 +402,13 @@ def validateAttributeValueId(self, token, tagName, attrName, attrValue):
399402
def validateAttributeValueTabindex(self, token, tagName, attrName, attrValue):
400403
for t in self.checkIntegerValue(token, tagName, attrName, attrValue) or []: yield t
401404

405+
def validateAttributeValueHtmlXmlns(self, token, tagName, attrName, attrValue):
406+
if attrValue != "http://www.w3.org/1999/xhtml":
407+
yield {"type": "ParseError",
408+
"data": "invalid-root-namespace",
409+
"datavars": {"tagName": tagName,
410+
"attributeName": attrName}}
411+
402412
##########################################################################
403413
# Attribute validation helpers
404414
##########################################################################

0 commit comments

Comments
 (0)