mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Bug #1442874: handle "<!>", the empty SGML comment
This commit is contained in:
parent
8f4b4db676
commit
d09def36d5
2 changed files with 5 additions and 2 deletions
|
@ -76,13 +76,16 @@ class ParserBase:
|
||||||
rawdata = self.rawdata
|
rawdata = self.rawdata
|
||||||
j = i + 2
|
j = i + 2
|
||||||
assert rawdata[i:j] == "<!", "unexpected call to parse_declaration"
|
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 ("-", ""):
|
if rawdata[j:j+1] in ("-", ""):
|
||||||
# Start of comment followed by buffer boundary,
|
# Start of comment followed by buffer boundary,
|
||||||
# or just a buffer boundary.
|
# or just a buffer boundary.
|
||||||
return -1
|
return -1
|
||||||
# A simple, practical version could look like: ((name|stringlit) S*) + '>'
|
# A simple, practical version could look like: ((name|stringlit) S*) + '>'
|
||||||
n = len(rawdata)
|
n = len(rawdata)
|
||||||
if rawdata[j:j+1] == '--': #comment
|
if rawdata[j:j+2] == '--': #comment
|
||||||
# Locate --.*-- as the body of the comment
|
# Locate --.*-- as the body of the comment
|
||||||
return self.parse_comment(i)
|
return self.parse_comment(i)
|
||||||
elif rawdata[j] == '[': #marked section
|
elif rawdata[j] == '[': #marked section
|
||||||
|
|
|
@ -115,7 +115,7 @@ comment1b-->
|
||||||
<Img sRc='Bar' isMAP>sample
|
<Img sRc='Bar' isMAP>sample
|
||||||
text
|
text
|
||||||
“
|
“
|
||||||
<!--comment2a-- --comment2b-->
|
<!--comment2a-- --comment2b--><!>
|
||||||
</Html>
|
</Html>
|
||||||
""", [
|
""", [
|
||||||
("data", "\n"),
|
("data", "\n"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue