diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-11-18 16:01:49 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-11-18 16:01:49 (GMT) |
commit | 15cb48923449bdd1325a7736a5f9bb73c8529cec (patch) | |
tree | ea68bd3978d6449acc9a3b7c65972922f6706ced /Lib/test/test_htmlparser.py | |
parent | 8008f2aba0c063a882c33ebd4b39a5a560deb8c0 (diff) | |
download | cpython-15cb48923449bdd1325a7736a5f9bb73c8529cec.zip cpython-15cb48923449bdd1325a7736a5f9bb73c8529cec.tar.gz cpython-15cb48923449bdd1325a7736a5f9bb73c8529cec.tar.bz2 |
#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.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py index 1ce4594..87b5060 100644 --- a/Lib/test/test_htmlparser.py +++ b/Lib/test/test_htmlparser.py @@ -301,7 +301,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 --> ¬-an-entity-ref; + <a href="" /> </p><p> <span></span></style> + '</script' + '>'""" + for element in [' script', 'script ', ' script ', + '\nscript', 'script\n', '\nscript\n']: + element_lower = element.lower().strip() + s = '<script>{content}</{element}>'.format(element=element, + content=content) + self._run_check(s, [("starttag", element_lower, []), + ("data", content), + ("endtag", element_lower)], + collector=Collector()) class HTMLParserTolerantTestCase(HTMLParserStrictTestCase): |