From: Georg Brandl Date: Thu, 9 Mar 2006 13:27:14 +0000 (+0000) Subject: Bug #1442874: handle "", the empty SGML comment X-Git-Tag: v2.5a0~302 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d09def36d52af3e087433eb67c49da633436c602;p=python Bug #1442874: handle "", the empty SGML comment --- diff --git a/Lib/markupbase.py b/Lib/markupbase.py index 3d00a74a92..85b07a2fdc 100644 --- a/Lib/markupbase.py +++ b/Lib/markupbase.py @@ -76,13 +76,16 @@ class ParserBase: rawdata = self.rawdata j = i + 2 assert rawdata[i:j] == "": + # the empty comment + return j + 1 if rawdata[j:j+1] in ("-", ""): # Start of comment followed by buffer boundary, # or just a buffer boundary. return -1 # A simple, practical version could look like: ((name|stringlit) S*) + '>' n = len(rawdata) - if rawdata[j:j+1] == '--': #comment + if rawdata[j:j+2] == '--': #comment # Locate --.*-- as the body of the comment return self.parse_comment(i) elif rawdata[j] == '[': #marked section diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py index 4cb87dfc21..54b90cd2de 100755 --- a/Lib/test/test_htmlparser.py +++ b/Lib/test/test_htmlparser.py @@ -115,7 +115,7 @@ comment1b--> sample text “ - + """, [ ("data", "\n"),