Commit d9e0b068 authored by Ezio Melotti's avatar Ezio Melotti

#12888: Fix a bug in HTMLParser.unescape that prevented it to escape more than...

#12888: Fix a bug in HTMLParser.unescape that prevented it to escape more than 128 entities.  Patch by Peter Otten.
parent 73abc243
...@@ -458,4 +458,4 @@ class HTMLParser(_markupbase.ParserBase): ...@@ -458,4 +458,4 @@ class HTMLParser(_markupbase.ParserBase):
return '&'+s+';' return '&'+s+';'
return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));", return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));",
replaceEntities, s, re.ASCII) replaceEntities, s, flags=re.ASCII)
...@@ -377,7 +377,8 @@ class HTMLParserTolerantTestCase(TestCaseBase): ...@@ -377,7 +377,8 @@ class HTMLParserTolerantTestCase(TestCaseBase):
p = html.parser.HTMLParser() p = html.parser.HTMLParser()
self.assertEqual(p.unescape('&#bad;'),'&#bad;') self.assertEqual(p.unescape('&#bad;'),'&#bad;')
self.assertEqual(p.unescape('&'),'&') self.assertEqual(p.unescape('&'),'&')
# see #12888
self.assertEqual(p.unescape('{ ' * 1050), '{ ' * 1050)
def test_main(): def test_main():
support.run_unittest(HTMLParserTestCase, HTMLParserTolerantTestCase) support.run_unittest(HTMLParserTestCase, HTMLParserTolerantTestCase)
......
...@@ -661,6 +661,7 @@ Douglas Orr ...@@ -661,6 +661,7 @@ Douglas Orr
Michele Orrù Michele Orrù
Oleg Oshmyan Oleg Oshmyan
Denis S. Otkidach Denis S. Otkidach
Peter Otten
Michael Otteneder Michael Otteneder
R. M. Oudkerk R. M. Oudkerk
Russel Owen Russel Owen
......
...@@ -25,6 +25,9 @@ Core and Builtins ...@@ -25,6 +25,9 @@ Core and Builtins
Library Library
------- -------
- Issue #12888: Fix a bug in HTMLParser.unescape that prevented it to escape
more than 128 entities. Patch by Peter Otten.
- Issue #12878: Expose a __dict__ attribute on io.IOBase and its subclasses. - Issue #12878: Expose a __dict__ attribute on io.IOBase and its subclasses.
- Issue #12636: IDLE reads the coding cookie when executing a Python script. - Issue #12636: IDLE reads the coding cookie when executing a Python script.
......
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