]> granicus.if.org Git - python/commitdiff
Bug #1442874: handle "<!>", the empty SGML comment
authorGeorg Brandl <georg@python.org>
Thu, 9 Mar 2006 13:27:14 +0000 (13:27 +0000)
committerGeorg Brandl <georg@python.org>
Thu, 9 Mar 2006 13:27:14 +0000 (13:27 +0000)
Lib/markupbase.py
Lib/test/test_htmlparser.py

index 3d00a74a92e9d68279139c7a5fa42b4edb2bc601..85b07a2fdcd831edb820cefbb5cd1bb5293521a4 100644 (file)
@@ -76,13 +76,16 @@ class ParserBase:
         rawdata = self.rawdata
         j = i + 2
         assert rawdata[i:j] == "<!", "unexpected call to parse_declaration"
+        if rawdata[j:j+1] == ">":
+            # 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
index 4cb87dfc215a24772991807f140f0d91478c85cc..54b90cd2de202277a83eb4a3ab22946275d019dc 100755 (executable)
@@ -115,7 +115,7 @@ comment1b-->
 <Img sRc='Bar' isMAP>sample
 text
 &#x201C;
-<!--comment2a-- --comment2b-->
+<!--comment2a-- --comment2b--><!>
 </Html>
 """, [
     ("data", "\n"),