summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2011-09-05 14:11:06 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2011-09-05 14:11:06 (GMT)
commitd9e0b068af175a2fc1c2fe979ab97b5d4f8239b7 (patch)
treec1d0984585611c4b99dbbdd02afb02a23736b5e8 /Lib
parent73abc243458e7d2e35e93d8df625b391cd4f7f62 (diff)
downloadcpython-d9e0b068af175a2fc1c2fe979ab97b5d4f8239b7.zip
cpython-d9e0b068af175a2fc1c2fe979ab97b5d4f8239b7.tar.gz
cpython-d9e0b068af175a2fc1c2fe979ab97b5d4f8239b7.tar.bz2
#12888: Fix a bug in HTMLParser.unescape that prevented it to escape more than 128 entities. Patch by Peter Otten.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/html/parser.py2
-rw-r--r--Lib/test/test_htmlparser.py3
2 files changed, 3 insertions, 2 deletions
diff --git a/Lib/html/parser.py b/Lib/html/parser.py
index 9412280..a6d5be9 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 637ab01..d45e453 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('&#0038;'),'&')
-
+ # see #12888
+ self.assertEqual(p.unescape('&#123; ' * 1050), '{ ' * 1050)
def test_main():
support.run_unittest(HTMLParserTestCase, HTMLParserTolerantTestCase)