diff --git a/.pytest.expect b/.pytest.expect index 5ec37054..8bfcf4b7 100644 --- a/.pytest.expect +++ b/.pytest.expect @@ -293,126 +293,6 @@ u'html5lib/tests/testdata/tree-construction/namespace-sensitivity.dat::0::cEleme u'html5lib/tests/testdata/tree-construction/namespace-sensitivity.dat::0::cElementTree::parser::void-namespace': FAIL u'html5lib/tests/testdata/tree-construction/namespace-sensitivity.dat::0::lxml::parser::namespaced': FAIL u'html5lib/tests/testdata/tree-construction/namespace-sensitivity.dat::0::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::0::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::0::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::0::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::0::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::0::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::0::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::0::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::0::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::11::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::11::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::11::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::11::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::11::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::11::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::11::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::11::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::12::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::12::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::12::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::12::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::12::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::12::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::12::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::12::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::13::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::13::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::13::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::13::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::13::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::13::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::13::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::13::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::14::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::14::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::14::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::14::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::14::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::14::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::14::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::14::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::15::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::15::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::15::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::15::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::15::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::15::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::15::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::15::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::1::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::1::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::1::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::1::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::1::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::1::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::1::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::1::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::4::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::4::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::4::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::4::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::4::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::4::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::4::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::4::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::5::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::5::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::5::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::5::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::5::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::5::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::5::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::5::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::6::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::6::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::6::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::6::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::6::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::6::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::6::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::6::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::7::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::7::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::7::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::7::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::7::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::7::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::7::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::7::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::8::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::8::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::8::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::8::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::8::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::8::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::8::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::8::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::lxml::parser::void-namespace': FAIL u'html5lib/tests/testdata/tree-construction/ruby.dat::0::DOM::parser::namespaced': FAIL u'html5lib/tests/testdata/tree-construction/ruby.dat::0::DOM::parser::void-namespace': FAIL u'html5lib/tests/testdata/tree-construction/ruby.dat::0::ElementTree::parser::namespaced': FAIL @@ -509,54 +389,6 @@ u'html5lib/tests/testdata/tree-construction/tests11.dat::2::cElementTree::parser u'html5lib/tests/testdata/tree-construction/tests11.dat::2::cElementTree::parser::void-namespace': FAIL u'html5lib/tests/testdata/tree-construction/tests11.dat::2::lxml::parser::namespaced': FAIL u'html5lib/tests/testdata/tree-construction/tests11.dat::2::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::181::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::181::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::181::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::181::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::181::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::181::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::181::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::181::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::183::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::183::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::183::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::183::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::183::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::183::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::183::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::183::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::185::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::185::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::185::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::185::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::185::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::185::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::185::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::185::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::84::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::84::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::84::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::84::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::84::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::84::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::84::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::84::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::86::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::86::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::86::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::86::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::86::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::86::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::86::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::86::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::88::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::88::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::88::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::88::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::88::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::88::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::88::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests16.dat::88::lxml::parser::void-namespace': FAIL u'html5lib/tests/testdata/tree-construction/tests19.dat::14::DOM::parser::namespaced': FAIL u'html5lib/tests/testdata/tree-construction/tests19.dat::14::DOM::parser::void-namespace': FAIL u'html5lib/tests/testdata/tree-construction/tests19.dat::14::ElementTree::parser::namespaced': FAIL @@ -605,14 +437,6 @@ u'html5lib/tests/testdata/tree-construction/tests25.dat::7::cElementTree::parser u'html5lib/tests/testdata/tree-construction/tests25.dat::7::cElementTree::parser::void-namespace': FAIL u'html5lib/tests/testdata/tree-construction/tests25.dat::7::lxml::parser::namespaced': FAIL u'html5lib/tests/testdata/tree-construction/tests25.dat::7::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests5.dat::16::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests5.dat::16::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests5.dat::16::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests5.dat::16::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests5.dat::16::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests5.dat::16::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/tests5.dat::16::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/tests5.dat::16::lxml::parser::void-namespace': FAIL u'html5lib/tests/testdata/tree-construction/webkit02.dat::14::DOM::parser::namespaced': FAIL u'html5lib/tests/testdata/tree-construction/webkit02.dat::14::DOM::parser::void-namespace': FAIL u'html5lib/tests/testdata/tree-construction/webkit02.dat::14::ElementTree::parser::namespaced': FAIL @@ -637,11 +461,3 @@ u'html5lib/tests/testdata/tree-construction/webkit02.dat::16::cElementTree::pars u'html5lib/tests/testdata/tree-construction/webkit02.dat::16::cElementTree::parser::void-namespace': FAIL u'html5lib/tests/testdata/tree-construction/webkit02.dat::16::lxml::parser::namespaced': FAIL u'html5lib/tests/testdata/tree-construction/webkit02.dat::16::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/webkit02.dat::2::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/webkit02.dat::2::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/webkit02.dat::2::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/webkit02.dat::2::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/webkit02.dat::2::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/webkit02.dat::2::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/webkit02.dat::2::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/webkit02.dat::2::lxml::parser::void-namespace': FAIL diff --git a/html5lib/constants.py b/html5lib/constants.py index f6e38cbf..2244933c 100644 --- a/html5lib/constants.py +++ b/html5lib/constants.py @@ -283,6 +283,12 @@ "Element %(name)s not allowed in a non-html context", "unexpected-end-tag-before-html": "Unexpected end tag (%(name)s) before html.", + "unexpected-inhead-noscript-tag": + "Element %(name)s not allowed in a inhead-noscript context", + "eof-in-head-noscript": + "Unexpected end of file. Expected inhead-noscript content", + "char-in-head-noscript": + "Unexpected non-space character. Expected inhead-noscript content", "XXX-undefined-error": "Undefined error (this sucks and should be fixed)", } diff --git a/html5lib/html5parser.py b/html5lib/html5parser.py index b56f6238..e6808425 100644 --- a/html5lib/html5parser.py +++ b/html5lib/html5parser.py @@ -22,18 +22,18 @@ def parse(doc, treebuilder="etree", encoding=None, - namespaceHTMLElements=True): + namespaceHTMLElements=True, scripting=False): """Parse a string or file-like object into a tree""" tb = treebuilders.getTreeBuilder(treebuilder) p = HTMLParser(tb, namespaceHTMLElements=namespaceHTMLElements) - return p.parse(doc, encoding=encoding) + return p.parse(doc, encoding=encoding, scripting=scripting) def parseFragment(doc, container="div", treebuilder="etree", encoding=None, - namespaceHTMLElements=True): + namespaceHTMLElements=True, scripting=False): tb = treebuilders.getTreeBuilder(treebuilder) p = HTMLParser(tb, namespaceHTMLElements=namespaceHTMLElements) - return p.parseFragment(doc, container=container, encoding=encoding) + return p.parseFragment(doc, container=container, encoding=encoding, scripting=scripting) def method_decorator_metaclass(function): @@ -78,11 +78,12 @@ def __init__(self, tree=None, tokenizer=tokenizer.HTMLTokenizer, self.phases = dict([(name, cls(self, self.tree)) for name, cls in getPhases(debug).items()]) - def _parse(self, stream, innerHTML=False, container="div", - encoding=None, parseMeta=True, useChardet=True, **kwargs): + def _parse(self, stream, innerHTML=False, container="div", encoding=None, + parseMeta=True, useChardet=True, scripting=False, **kwargs): self.innerHTMLMode = innerHTML self.container = container + self.scripting = scripting self.tokenizer = self.tokenizer_class(stream, encoding=encoding, parseMeta=parseMeta, useChardet=useChardet, @@ -221,7 +222,8 @@ def normalizedTokens(self): for token in self.tokenizer: yield self.normalizeToken(token) - def parse(self, stream, encoding=None, parseMeta=True, useChardet=True): + def parse(self, stream, encoding=None, parseMeta=True, + useChardet=True, scripting=False): """Parse a HTML document into a well-formed tree stream - a filelike object or string containing the HTML to be parsed @@ -230,13 +232,15 @@ def parse(self, stream, encoding=None, parseMeta=True, useChardet=True): the encoding. If specified, that encoding will be used, regardless of any BOM or later declaration (such as in a meta element) + + scripting - treat noscript elements as if javascript was turned on """ self._parse(stream, innerHTML=False, encoding=encoding, - parseMeta=parseMeta, useChardet=useChardet) + parseMeta=parseMeta, useChardet=useChardet, scripting=scripting) return self.tree.getDocument() def parseFragment(self, stream, container="div", encoding=None, - parseMeta=False, useChardet=True): + parseMeta=False, useChardet=True, scripting=False): """Parse a HTML fragment into a well-formed tree fragment container - name of the element we're setting the innerHTML property @@ -248,8 +252,11 @@ def parseFragment(self, stream, container="div", encoding=None, the encoding. If specified, that encoding will be used, regardless of any BOM or later declaration (such as in a meta element) + + scripting - treat noscript elements as if javascript was turned on """ - self._parse(stream, True, container=container, encoding=encoding) + self._parse(stream, True, container=container, + encoding=encoding, scripting=scripting) return self.tree.getFragment() def parseError(self, errorcode="XXX-undefined-error", datavars={}): @@ -708,7 +715,8 @@ def __init__(self, parser, tree): self.startTagHandler = utils.MethodDispatcher([ ("html", self.startTagHtml), ("title", self.startTagTitle), - (("noscript", "noframes", "style"), self.startTagNoScriptNoFramesStyle), + (("noframes", "style"), self.startTagNoFramesStyle), + ("noscript", self.startTagNoscript), ("script", self.startTagScript), (("base", "basefont", "bgsound", "command", "link"), self.startTagBaseLinkCommand), @@ -717,7 +725,7 @@ def __init__(self, parser, tree): ]) self.startTagHandler.default = self.startTagOther - self. endTagHandler = utils.MethodDispatcher([ + self.endTagHandler = utils.MethodDispatcher([ ("head", self.endTagHead), (("br", "html", "body"), self.endTagHtmlBodyBr) ]) @@ -767,10 +775,17 @@ def startTagMeta(self, token): def startTagTitle(self, token): self.parser.parseRCDataRawtext(token, "RCDATA") - def startTagNoScriptNoFramesStyle(self, token): + def startTagNoFramesStyle(self, token): # Need to decide whether to implement the scripting-disabled case self.parser.parseRCDataRawtext(token, "RAWTEXT") + def startTagNoscript(self, token): + if self.parser.scripting: + self.parser.parseRCDataRawtext(token, "RAWTEXT") + else: + self.tree.insertElement(token) + self.parser.phase = self.parser.phases["inHeadNoscript"] + def startTagScript(self, token): self.tree.insertElement(token) self.parser.tokenizer.state = self.parser.tokenizer.scriptDataState @@ -796,10 +811,70 @@ def endTagOther(self, token): def anythingElse(self): self.endTagHead(impliedTagToken("head")) - # XXX If we implement a parser for which scripting is disabled we need to - # implement this phase. - # - # class InHeadNoScriptPhase(Phase): + class InHeadNoscriptPhase(Phase): + def __init__(self, parser, tree): + Phase.__init__(self, parser, tree) + + self.startTagHandler = utils.MethodDispatcher([ + ("html", self.startTagHtml), + (("basefont", "bgsound", "link", "meta", "noframes", "style"), self.startTagBaseLinkCommand), + (("head", "noscript"), self.startTagHeadNoscript), + ]) + self.startTagHandler.default = self.startTagOther + + self.endTagHandler = utils.MethodDispatcher([ + ("noscript", self.endTagNoscript), + ("br", self.endTagBr), + ]) + self.endTagHandler.default = self.endTagOther + + def processEOF(self): + self.parser.parseError("eof-in-head-noscript") + self.anythingElse() + return True + + def processComment(self, token): + return self.parser.phases["inHead"].processComment(token) + + def processCharacters(self, token): + self.parser.parseError("char-in-head-noscript") + self.anythingElse() + return token + + def processSpaceCharacters(self, token): + return self.parser.phases["inHead"].processSpaceCharacters(token) + + def startTagHtml(self, token): + return self.parser.phases["inBody"].processStartTag(token) + + def startTagBaseLinkCommand(self, token): + return self.parser.phases["inHead"].processStartTag(token) + + def startTagHeadNoscript(self, token): + self.parser.parseError("unexpected-start-tag", {"name": token["name"]}) + + def startTagOther(self, token): + self.parser.parseError("unexpected-inhead-noscript-tag", {"name": token["name"]}) + self.anythingElse() + return token + + def endTagNoscript(self, token): + node = self.parser.tree.openElements.pop() + assert node.name == "noscript", "Expected noscript got %s" % node.name + self.parser.phase = self.parser.phases["inHead"] + + def endTagBr(self, token): + self.parser.parseError("unexpected-inhead-noscript-tag", {"name": token["name"]}) + self.anythingElse() + return token + + def endTagOther(self, token): + self.parser.parseError("unexpected-end-tag", {"name": token["name"]}) + + def anythingElse(self): + # Caller must raise parse error first! + self.endTagNoscript(impliedTagToken("noscript")) + class AfterHeadPhase(Phase): def __init__(self, parser, tree): Phase.__init__(self, parser, tree) @@ -910,7 +985,8 @@ def __init__(self, parser, tree): ("isindex", self.startTagIsIndex), ("textarea", self.startTagTextarea), ("iframe", self.startTagIFrame), - (("noembed", "noframes", "noscript"), self.startTagRawtext), + ("noscript", self.startTagNoscript), + (("noembed", "noframes"), self.startTagRawtext), ("select", self.startTagSelect), (("rp", "rt"), self.startTagRpRt), (("option", "optgroup"), self.startTagOpt), @@ -1231,6 +1307,12 @@ def startTagIFrame(self, token): self.parser.framesetOK = False self.startTagRawtext(token) + def startTagNoscript(self, token): + if self.parser.scripting: + self.startTagRawtext(token) + else: + self.startTagOther(token) + def startTagRawtext(self, token): """iframe, noembed noframes, noscript(if scripting enabled)""" self.parser.parseRCDataRawtext(token, "RAWTEXT") @@ -2687,7 +2769,7 @@ def processEndTag(self, token): "beforeHtml": BeforeHtmlPhase, "beforeHead": BeforeHeadPhase, "inHead": InHeadPhase, - # XXX "inHeadNoscript": InHeadNoScriptPhase, + "inHeadNoscript": InHeadNoscriptPhase, "afterHead": AfterHeadPhase, "inBody": InBodyPhase, "text": TextPhase, diff --git a/html5lib/tests/tree_construction.py b/html5lib/tests/tree_construction.py index fda850ed..c6e7ca09 100644 --- a/html5lib/tests/tree_construction.py +++ b/html5lib/tests/tree_construction.py @@ -97,13 +97,17 @@ def runtest(self): expected = convertExpected(self.test['document']) expectedErrors = self.test['errors'].split("\n") if self.test['errors'] else [] + scripting = False + if 'script-on' in self.test: + scripting = True + with warnings.catch_warnings(): warnings.simplefilter("error") try: if fragmentContainer: - document = p.parseFragment(input, fragmentContainer) + document = p.parseFragment(input, fragmentContainer, scripting=scripting) else: - document = p.parse(input) + document = p.parse(input, scripting=scripting) except constants.DataLossWarning: pytest.skip("data loss warning") @@ -153,13 +157,17 @@ def runtest(self): fragmentContainer = self.test['document-fragment'] expected = convertExpected(self.test['document']) + scripting = False + if 'script-on' in self.test: + scripting = True + with warnings.catch_warnings(): warnings.simplefilter("error") try: if fragmentContainer: - document = p.parseFragment(input, fragmentContainer) + document = p.parseFragment(input, fragmentContainer, scripting=scripting) else: - document = p.parse(input) + document = p.parse(input, scripting=scripting) except constants.DataLossWarning: pytest.skip("data loss warning") diff --git a/parse.py b/parse.py index b9bea288..2245060a 100755 --- a/parse.py +++ b/parse.py @@ -65,11 +65,12 @@ def parse(): if opts.profile: import cProfile import pstats - cProfile.runctx("run(parseMethod, f, encoding)", None, + cProfile.runctx("run(parseMethod, f, encoding, scripting)", None, {"run": run, "parseMethod": parseMethod, "f": f, - "encoding": encoding}, + "encoding": encoding, + "scripting": opts.scripting}, "stats.prof") # XXX - We should use a temp file here stats = pstats.Stats('stats.prof') @@ -79,7 +80,7 @@ def parse(): elif opts.time: import time t0 = time.time() - document = run(parseMethod, f, encoding) + document = run(parseMethod, f, encoding, opts.scripting) t1 = time.time() if document: printOutput(p, document, opts) @@ -88,13 +89,13 @@ def parse(): else: sys.stderr.write("\n\nRun took: %fs"%(t1-t0)) else: - document = run(parseMethod, f, encoding) + document = run(parseMethod, f, encoding, opts.scripting) if document: printOutput(p, document, opts) -def run(parseMethod, f, encoding): +def run(parseMethod, f, encoding, scripting): try: - document = parseMethod(f, encoding=encoding) + document = parseMethod(f, encoding=encoding, scripting=scripting) except: document = None traceback.print_exc() @@ -168,6 +169,9 @@ def getOptParser(): parser.add_option("-f", "--fragment", action="store_true", default=False, dest="fragment", help="Parse as a fragment") + parser.add_option("-s", "--scripting", action="store_true", default=False, + dest="scripting", help="Handle noscript tags as if scripting was enabled") + parser.add_option("", "--tree", action="store_true", default=False, dest="tree", help="Output as debug tree")