mirror of
https://github.com/python/cpython.git
synced 2025-07-10 04:45:36 +00:00
[3.13] gh-77057: Fix handling of invalid markup declarations in HTMLParser (GH-9295) (GH-133834)
(cherry picked from commit 76c0b01bc4
)
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
3de6546381
commit
aa0c3d1098
3 changed files with 68 additions and 19 deletions
|
@ -278,7 +278,7 @@ class HTMLParser(_markupbase.ParserBase):
|
|||
if rawdata[i:i+4] == '<!--':
|
||||
# this case is actually already handled in goahead()
|
||||
return self.parse_comment(i)
|
||||
elif rawdata[i:i+3] == '<![':
|
||||
elif rawdata[i:i+9] == '<![CDATA[':
|
||||
return self.parse_marked_section(i)
|
||||
elif rawdata[i:i+9].lower() == '<!doctype':
|
||||
# find the closing >
|
||||
|
@ -295,7 +295,7 @@ class HTMLParser(_markupbase.ParserBase):
|
|||
def parse_bogus_comment(self, i, report=1):
|
||||
rawdata = self.rawdata
|
||||
assert rawdata[i:i+2] in ('<!', '</'), ('unexpected call to '
|
||||
'parse_comment()')
|
||||
'parse_bogus_comment()')
|
||||
pos = rawdata.find('>', i+2)
|
||||
if pos == -1:
|
||||
return -1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue