Skip to content

Commit 77ee77d

Browse files
committed
Fix handling of </form> in in body and null publicId / systemId in doctypes
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%401137
1 parent 9f8929b commit 77ee77d

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/html5lib/html5parser.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -314,16 +314,20 @@ def processComment(self, data):
314314

315315
def processDoctype(self, name, publicId, systemId, correct):
316316
nameLower = name.translate(asciiUpper2Lower)
317-
if nameLower != "html" or publicId != None or\
318-
systemId != None:
317+
if (nameLower != "html" or publicId != None or
318+
systemId != None):
319319
self.parser.parseError("unknown-doctype")
320-
# XXX need to update DOCTYPE tokens
321-
self.tree.insertDoctype(name, publicId, systemId)
322320

323-
if publicId == None:
324-
publicId = ""
321+
if publicId is None:
322+
publicId = ""
323+
if systemId is None:
324+
systemId = ""
325+
326+
self.tree.insertDoctype(name, publicId, systemId)
327+
325328
if publicId != "":
326-
publicId = publicId.translate(asciiUpper2Lower)
329+
publicId = publicId.translate(asciiUpper2Lower)
330+
327331

328332
if (not correct) or nameLower != "html"\
329333
or publicId in\
@@ -1064,14 +1068,18 @@ def endTagBlock(self, name):
10641068
node = self.tree.openElements.pop()
10651069

10661070
def endTagForm(self, name):
1067-
if self.tree.elementInScope(name):
1068-
self.tree.generateImpliedEndTags()
1069-
if self.tree.openElements[-1].name != name:
1070-
self.parser.parseError("end-tag-too-early-ignored",
1071-
{"name": "form"})
1072-
else:
1073-
self.tree.openElements.pop()
10741071
self.tree.formPointer = None
1072+
if not self.tree.elementInScope(name):
1073+
self.parser.parseError("unexpected-end-tag",
1074+
{"name":"form"})
1075+
else:
1076+
self.tree.generateImpliedEndTags()
1077+
if self.tree.openElements[-1].name != name:
1078+
self.parser.parseError("end-tag-too-early-ignored",
1079+
{"name": "form"})
1080+
node = self.tree.openElements.pop()
1081+
while node.name != name:
1082+
node = self.tree.openElements.pop()
10751083

10761084
def endTagListItem(self, name):
10771085
# AT Could merge this with the Block case

0 commit comments

Comments
 (0)