summaryrefslogtreecommitdiff
path: root/Lib/test/test_htmlparser.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2011-11-18 18:00:40 +0200
committerEzio Melotti <ezio.melotti@gmail.com>2011-11-18 18:00:40 +0200
commit00dc60beee3bf4b68fd658716616f25503a3a9eb (patch)
treef229f62cf4c74e6692181a0cc91a1fc12fd06e63 /Lib/test/test_htmlparser.py
parent93bbb6a9a641d54c242651e97948c15be911c9bb (diff)
downloadcpython-git-00dc60beee3bf4b68fd658716616f25503a3a9eb.tar.gz
#13358: HTMLParser now calls handle_data only once for each CDATA.
Diffstat (limited to 'Lib/test/test_htmlparser.py')
-rw-r--r--Lib/test/test_htmlparser.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py
index b84e7dc935..5dfe466225 100644
--- a/Lib/test/test_htmlparser.py
+++ b/Lib/test/test_htmlparser.py
@@ -286,6 +286,27 @@ DOCTYPE html [
("data", content),
("endtag", element_lower)])
+ def test_cdata_with_closing_tags(self):
+ # see issue #13358
+ # make sure that HTMLParser calls handle_data only once for each CDATA.
+ # The normal event collector normalizes the events in get_events,
+ # so we override it to return the original list of events.
+ class Collector(EventCollector):
+ def get_events(self):
+ return self.events
+
+ content = """<!-- not a comment --> &not-an-entity-ref;
+ <a href="" /> </p><p> &amp; <span></span></style>
+ '</script' + '>' </html> </head> </scripter>!"""
+ for element in [' script', 'script ', ' script ',
+ '\nscript', 'script\n', '\nscript\n']:
+ s = u'<script>{content}</{element}>'.format(element=element,
+ content=content)
+ self._run_check(s, [("starttag", "script", []),
+ ("data", content),
+ ("endtag", "script")],
+ collector=Collector)
+
def test_malformatted_charref(self):
self._run_check("<p>&#bad;</p>", [
("starttag", "p", []),