8000 remove a parse error and useless check in the close tag open state pe… · awesome-python/html5lib-python@f66a879 · GitHub
[go: up one dir, main page]

Skip to content

Commit f66a879

Browse files
committed
remove a parse error and useless check in the close tag open state per spec change and update test to match that
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40756
1 parent 5b08a4b commit f66a879

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

src/tokenizer.py

Lines changed: 19 additions & 23 deletions
10553
Original file line numberDiff line numberDiff line change
@@ -379,36 +379,32 @@ def closeTagOpenState(self):
379379
# emitting the end tag token.
380380
self.contentModelFlag = contentModelFlags["PCDATA"]
381381
else:
382-
self.tokenQueue.append({"type": "ParseError", "data":
383-
_("Expected closing tag after seeing '</'. None found.")})
384382
self.tokenQueue.append({"type": "Characters", "data": u"</"})
385383
self.state = self.states["data"]
386384

387385
# Need to return here since we don't want the rest of the
388386
# method to be walked through.
389387
return True
390388

391-
if self.contentModelFlag == contentModelFlags["PCDATA"]:
392-
data = self.stream.char()
393-
if data in asciiLetters:
394-
self.currentToken =\
395-
{"type": "EndTag", "name": data, "data": []}
396-
self.state = self.states["tagName"]
397-
elif data == u">":
398-
self.tokenQueue.append({"type": "ParseError", "data":
399-
_("Expected closing tag. Got '>' instead. Ignoring '</>'.")})
400-
self.state = self.states["data"]
401-
elif data == EOF:
402-
self.tokenQueue.append({"type": "ParseError", "data":
403-
_("Expected closing tag. Unexpected end of file.")})
404-
self.tokenQueue.append({"type": "Characters", "data": u"</"})
405-
self.state = self.states["data"]
406-
else:
407-
# XXX data can be _'_...
408-
self.tokenQueue.append({"type": "ParseError", "data":
409-
_("Expected closing tag. Unexpected character '" + data + "' found.")})
410-
self.stream.queue.append(data)
411-
self.state = self.states["bogusComment"]
389+
data = self.stream.char()
390+
if data in asciiLetters:
391+
self.currentToken = {"type":"EndTag", "name":data, "data":[]}
392+
self.state = self.states["tagName"]
393+
elif data == u">":
394+
self.tokenQueue.append({"type": "ParseError", "data":
395+
_("Expected closing tag. Got '>' instead. Ignoring '</>'.")})
396+
self.state = self.states["data"]
397+
elif data == EOF:
398+
self.tokenQueue.append({"type": "ParseError", "data":
399+
_("Expected closing tag. Unexpected end of file.")})
400+
self.tokenQueue.append({"type": "Characters", "data": u"</"})
401+
self.state = self.states["data"]
402+
else:
403+
# XXX data can be _'_...
404+
self.tokenQueue.append({"type": "ParseError", "data":
405+
_("Expected closing tag. Unexpected character '" + data + "' found.")})
406+
self.stream.queue.append(data)
407+
self.state = self.states["bogusComment"]
412408
return True
413409

414410
def tagNameState(self):

tests/mockParser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import sys, hotshot, hotshot.stats
1+
import sys
2+
#import hotshot, hotshot.stats
23
import os
34

45
if __name__ == '__main__':

0 commit comments

Comments
 (0)
0