From: Ezio Melotti Date: Mon, 5 Sep 2011 14:11:06 +0000 (+0300) Subject: #12888: Fix a bug in HTMLParser.unescape that prevented it to escape more than 128... X-Git-Tag: v3.2.3rc1~581^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d9e0b068af175a2fc1c2fe979ab97b5d4f8239b7;p=thirdparty%2FPython%2Fcpython.git #12888: Fix a bug in HTMLParser.unescape that prevented it to escape more than 128 entities. Patch by Peter Otten. --- diff --git a/Lib/html/parser.py b/Lib/html/parser.py index 941228072a3c..a6d5be94fa33 100644 --- a/Lib/html/parser.py +++ b/Lib/html/parser.py @@ -458,4 +458,4 @@ class HTMLParser(_markupbase.ParserBase): return '&'+s+';' return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));", - replaceEntities, s, re.ASCII) + replaceEntities, s, flags=re.ASCII) diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py index 637ab01f1262..d45e45327fe8 100644 --- a/Lib/test/test_htmlparser.py +++ b/Lib/test/test_htmlparser.py @@ -377,7 +377,8 @@ class HTMLParserTolerantTestCase(TestCaseBase): p = html.parser.HTMLParser() self.assertEqual(p.unescape('&#bad;'),'&#bad;') self.assertEqual(p.unescape('&'),'&') - + # see #12888 + self.assertEqual(p.unescape('{ ' * 1050), '{ ' * 1050) def test_main(): support.run_unittest(HTMLParserTestCase, HTMLParserTolerantTestCase) diff --git a/Misc/ACKS b/Misc/ACKS index 7096d728d284..45ab6a44fa7c 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -661,6 +661,7 @@ Douglas Orr Michele Orrù Oleg Oshmyan Denis S. Otkidach +Peter Otten Michael Otteneder R. M. Oudkerk Russel Owen diff --git a/Misc/NEWS b/Misc/NEWS index c12bda23a987..ff1a0add4218 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -25,6 +25,9 @@ Core and Builtins 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 #12636: IDLE reads the coding cookie when executing a Python script.