Kaydet (Commit) 5a88853b authored tarafından Ezio Melotti's avatar Ezio Melotti

#20288: fix handling of invalid numeric charrefs in HTMLParser.

üst 383952d5
......@@ -195,9 +195,9 @@ class HTMLParser(markupbase.ParserBase):
i = self.updatepos(i, k)
continue
else:
if ";" in rawdata[i:]: #bail by consuming &#
self.handle_data(rawdata[0:2])
i = self.updatepos(i, 2)
if ";" in rawdata[i:]: # bail by consuming '&#'
self.handle_data(rawdata[i:i+2])
i = self.updatepos(i, i+2)
break
elif startswith('&', i):
match = entityref.match(rawdata, i)
......
......@@ -394,6 +394,12 @@ text
("data", "&#bad;"),
("endtag", "p"),
])
# add the [] as a workaround to avoid buffering (see #20288)
self._run_check(["<div>&#bad;</div>"], [
("starttag", "div", []),
("data", "&#bad;"),
("endtag", "div"),
])
def test_unescape_function(self):
parser = HTMLParser.HTMLParser()
......
......@@ -38,6 +38,8 @@ Core and Builtins
Library
-------
- Issue #20288: fix handling of invalid numeric charrefs in HTMLParser.
- Issue #19456: ntpath.join() now joins relative paths correctly when a drive
is present.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment