|
18 | 18 | from constants import scopingElements, formattingElements, specialElements
|
19 | 19 | from constants import headingElements, tableInsertModeElements
|
20 | 20 | from constants import cdataElements, rcdataElements, voidElements
|
21 |
| -from constants import tokenTypes, ReparseException |
22 |
| -from constants import tokenTypes, namespaces |
| 21 | +from constants import tokenTypes, ReparseException, namespaces |
23 | 22 |
|
24 | 23 | def parse(doc, treebuilder="simpletree", encoding=None):
|
25 | 24 | tb = treebuilders.getTreeBuilder(treebuilder)
|
@@ -677,7 +676,7 @@ def __init__(self, parser, tree):
|
677 | 676 |
|
678 | 677 | self. endTagHandler = utils.MethodDispatcher([
|
679 | 678 | ("head", self.endTagHead),
|
680 |
| - ("br", self.endTagBr) |
| 679 | + (("br", "html", "body"), self.endTagHtmlBodyBr) |
681 | 680 | ])
|
682 | 681 | self.endTagHandler.default = self.endTagOther
|
683 | 682 |
|
@@ -746,7 +745,7 @@ def endTagHead(self, token):
|
746 | 745 | assert node.name == "head", "Expected head got %s"%node.name
|
747 | 746 | self.parser.phase = self.parser.phases["afterHead"]
|
748 | 747 |
|
749 |
| - def endTagBr(self, token): |
| 748 | + def endTagHtmlBodyBr(self, token): |
750 | 749 | self.anythingElse()
|
751 | 750 | self.parser.phase.processEndTag(token)
|
752 | 751 |
|
@@ -775,7 +774,8 @@ def __init__(self, parser, tree):
|
775 | 774 | ("head", self.startTagHead)
|
776 | 775 | ])
|
777 | 776 | self.startTagHandler.default = self.startTagOther
|
778 |
| - self.endTagHandler = utils.MethodDispatcher([("br", self.endTagBr)]) |
| 777 | + self.endTagHandler = utils.MethodDispatcher([(("body", "html", "br"), |
| 778 | + self.endTagHtmlBodyBr)]) |
779 | 779 | self.endTagHandler.default = self.endTagOther
|
780 | 780 |
|
781 | 781 | def processEOF(self):
|
@@ -811,7 +811,7 @@ def startTagOther(self, token):
|
811 | 811 | self.anythingElse()
|
812 | 812 | self.parser.phase.processStartTag(token)
|
813 | 813 |
|
814 |
| - def endTagBr(self, token): |
| 814 | + def endTagHtmlBodyBr(self, token): |
815 | 815 | #This is not currently in the spec
|
816 | 816 | self.anythingElse()
|
817 | 817 | self.parser.phase.processEndTag(token)
|
@@ -1002,6 +1002,9 @@ def startTagPlaintext(self, token):
|
1002 | 1002 | def startTagHeading(self, token):
|
1003 | 1003 | if self.tree.elementInScope("p"):
|
1004 | 1004 | self.endTagP(impliedTagToken("p"))
|
| 1005 | + if self.tree.openElements[-1].name in headingElements: |
| 1006 | + self.parser.parseError("unexpected-start-tag", {"name": token["name"]}) |
| 1007 | + self.tree.openElements.pop() |
1005 | 1008 | # Uncomment the following for IE7 behavior:
|
1006 | 1009 | #
|
1007 | 1010 | #for item in headingElements:
|
@@ -1586,7 +1589,8 @@ def startTagStyleScript(self, token):
|
1586 | 1589 | self.startTagOther(token)
|
1587 | 1590 |
|
1588 | 1591 | def startTagInput(self, token):
|
1589 |
| - if "type" in token["data"] and token["data"]["type"].translate(asciiUpper2Lower) == "hidden" and "tainted" not in self.getCurrentTable()._flags: |
| 1592 | + if ("type" in token["data"] and |
| 1593 | + token["data"]["type"].translate(asciiUpper2Lower) == "hidden"): |
1590 | 1594 | self.parser.parseError("unexpected-hidden-input-in-table")
|
1591 | 1595 | self.tree.insertElement(token)
|
1592 | 1596 | # XXX associate with form
|
|
0 commit comments