[Python-checkins] r42938 - in python/trunk/Lib: markupbase.py test/test_htmlparser.py

georg.brandl python-checkins at python.org
Thu Mar 9 14:27:15 CET 2006


Author: georg.brandl
Date: Thu Mar  9 14:27:14 2006
New Revision: 42938

Modified:
   python/trunk/Lib/markupbase.py
   python/trunk/Lib/test/test_htmlparser.py
Log:
Bug #1442874: handle "<!>", the empty SGML comment



Modified: python/trunk/Lib/markupbase.py
==============================================================================
--- python/trunk/Lib/markupbase.py	(original)
+++ python/trunk/Lib/markupbase.py	Thu Mar  9 14:27:14 2006
@@ -76,13 +76,16 @@
         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

Modified: python/trunk/Lib/test/test_htmlparser.py
==============================================================================
--- python/trunk/Lib/test/test_htmlparser.py	(original)
+++ python/trunk/Lib/test/test_htmlparser.py	Thu Mar  9 14:27:14 2006
@@ -115,7 +115,7 @@
 <Img sRc='Bar' isMAP>sample
 text
 &#x201C;
-<!--comment2a-- --comment2b-->
+<!--comment2a-- --comment2b--><!>
 </Html>
 """, [
     ("data", "\n"),


More information about the Python-checkins mailing list