Skip to content

Commit ada0ac3

Browse files
committed
fix some more parse error messages: after frameset phase, after body phase, select phase
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40483
1 parent 1c22239 commit ada0ac3

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

src/html5parser.py

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ def __init__(self, parser, tree):
15311531
("optgroup", self.startTagOptgroup),
15321532
("select", self.startTagSelect)
15331533
])
1534-
self.startTagHandler.default = self.processAnythingElse
1534+
self.startTagHandler.default = self.startTagOther
15351535

15361536
self.endTagHandler = utils.MethodDispatcher([
15371537
("option", self.endTagOption),
@@ -1540,7 +1540,7 @@ def __init__(self, parser, tree):
15401540
(("caption", "table", "tbody", "tfoot", "thead", "tr", "td",
15411541
"th"), self.endTagTableElements)
15421542
])
1543-
self.endTagHandler.default = self.processAnythingElse
1543+
self.endTagHandler.default = self.endTagOther
15441544

15451545
# http://www.whatwg.org/specs/web-apps/current-work/#in-select
15461546
def processCharacters(self, data):
@@ -1563,6 +1563,10 @@ def startTagSelect(self, name, attributes):
15631563
self.parser.parseError()
15641564
self.endTagSelect("select")
15651565

1566+
def startTagOther(self, name, attributes):
1567+
self.parser.parseError(_(u"Unexpected start tag token (" + name +\
1568+
u") in the select phase. Ignored."))
1569+
15661570
def endTagOption(self, name):
15671571
if self.tree.openElements[-1].name == "option":
15681572
self.tree.openElements.pop()
@@ -1597,8 +1601,9 @@ def endTagTableElements(self, name):
15971601
self.endTagSelect()
15981602
self.parser.phase.processEndTag(name)
15991603

1600-
def processAnythingElse(self, name, attributes={}):
1601-
self.parser.parseError()
1604+
def endTagOther(self, name):
1605+
self.parser.parseError(_(u"Unexpected end tag token (" + name +\
1606+
u") in the select phase. Ignored."))
16021607

16031608

16041609
class AfterBodyPhase(Phase):
@@ -1615,12 +1620,14 @@ def processComment(self, data):
16151620
self.tree.insertComment(data, self.tree.openElements[0])
16161621

16171622
def processCharacters(self, data):
1618-
self.parser.parseError()
1623+
self.parser.parseError(_(u"Unexpected non-space characters in the "
1624+
u"after body phase."))
16191625
self.parser.phase = self.parser.phases["inBody"]
16201626
self.parser.phase.processCharacters(data)
16211627

16221628
def processStartTag(self, name, attributes):
1623-
self.parser.parseError()
1629+
self.parser.parseError(_(u"Unexpected start tag token (" + name +\
1630+
u") in the after body phase."))
16241631
self.parser.phase = self.parser.phases["inBody"]
16251632
self.parser.phase.processStartTag(name, attributes)
16261633

@@ -1632,7 +1639,8 @@ def endTagHtml(self,name):
16321639
self.parser.phase = self.parser.phases["trailingEnd"]
16331640

16341641
def endTagOther(self, name):
1635-
self.parser.parseError()
1642+
self.parser.parseError(_(u"Unexpected end tag token (" + name +\
1643+
u") in the after body phase."))
16361644
self.parser.phase = self.parser.phases["inBody"]
16371645
self.parser.phase.processEndTag(name)
16381646

@@ -1656,8 +1664,8 @@ def __init__(self, parser, tree):
16561664
self.endTagHandler.default = self.endTagOther
16571665

16581666
def processCharacters(self, data):
1659-
self.parser.parseError(_("Unepxected characters in the frameset phase. "
1660-
"Characters ignored."))
1667+
self.parser.parseError(_(u"Unepxected characters in "
1668+
u"the frameset phase. Characters ignored."))
16611669

16621670
def startTagFrameset(self, name, attributes):
16631671
self.tree.insertElement(name, attributes)
@@ -1670,14 +1678,14 @@ def startTagNoframes(self, name, attributes):
16701678
self.parser.phases["inBody"].processStartTag(name, attributes)
16711679

16721680
def startTagOther(self, name, attributes):
1673-
self.parser.parseError(_("Unexpected start tag token (" + name +\
1674-
") in the frameset phase."))
1681+
self.parser.parseError(_(u"Unexpected start tag token (" + name +\
1682+
u") in the frameset phase. Ignored"))
16751683

16761684
def endTagFrameset(self, name):
16771685
if self.tree.openElements[-1].name == "html":
16781686
# innerHTML case
1679-
self.parser.parseError(_("Unexpected end tag token (frameset) in the"
1680-
"frameset phase (innerHTML)"))
1687+
self.parser.parseError(_(u"Unexpected end tag token (frameset)"
1688+
u"in the frameset phase (innerHTML)."))
16811689
else:
16821690
self.tree.openElements.pop()
16831691
if not self.parser.innerHTML and\
@@ -1690,8 +1698,8 @@ def endTagNoframes(self, name):
16901698
self.parser.phases["inBody"].processEndTag(name)
16911699

16921700
def endTagOther(self, name):
1693-
self.parser.parseError(_("Unexpected end tag token (" + name +
1694-
") in the frameset phase."))
1701+
self.parser.parseError(_(u"Unexpected end tag token (" + name +
1702+
u") in the frameset phase. Ignored."))
16951703

16961704

16971705
class AfterFramesetPhase(Phase):
@@ -1711,20 +1719,23 @@ def __init__(self, parser, tree):
17111719
self.endTagHandler.default = self.endTagOther
17121720

17131721
def processCharacters(self, data):
1714-
self.parser.parseError()
1722+
self.parser.parseError(_(u"Unexpected non-space characters in the "
1723+
u"after frameset phase. Ignored."))
17151724

17161725
def startTagNoframes(self, name, attributes):
17171726
self.parser.phases["inBody"].processStartTag(name, attributes)
17181727

17191728
def startTagOther(self, name, attributes):
1720-
self.parser.parseError()
1729+
self.parser.parseError(_(u"Unexpected start tag (" + name +\
1730+
u") in the after frameset phase. Ignored."))
17211731

17221732
def endTagHtml(self, name):
17231733
self.parser.lastPhase = self.parser.phase
17241734
self.parser.phase = self.parser.phases["trailingEnd"]
17251735

17261736
def endTagOther(self, name):
1727-
self.parser.parseError()
1737+
self.parser.parseError(_(u"Unexpected end tag (" + name +\
1738+
u") in the after frameset phase. Ignored."))
17281739

17291740

17301741
class TrailingEndPhase(Phase):
@@ -1738,8 +1749,8 @@ def processSpaceCharacters(self, data):
17381749
self.parser.lastPhase.processCharacters(data)
17391750

17401751
def processCharacters(self, data):
1741-
self.parser.parseError(_("Unexpected non-space characters. "u
1742-
"Expected end of file."))
1752+
self.parser.parseError(_(u"Unexpected non-space characters. "
1753+
u"Expected end of file."))
17431754
self.parser.phase = self.parser.lastPhase
17441755
self.parser.phase.processCharacters(data)
17451756

0 commit comments

Comments
 (0)