From 7de56f6a04ab60010b3e2185752b3ddf681d068d Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Tue, 1 Nov 2011 14:12:22 +0200 Subject: #670664: Fix HTMLParser to correctly handle the content of ```` and ````. --- Lib/test/test_htmlparser.py | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'Lib/test/test_htmlparser.py') diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py index 9664485513..fd8447c91d 100644 --- a/Lib/test/test_htmlparser.py +++ b/Lib/test/test_htmlparser.py @@ -321,18 +321,36 @@ DOCTYPE html [ ("starttag_text", s)]) def test_cdata_content(self): - s = """""" - self._run_check(s, [ - ("starttag", "script", []), - ("data", " ¬-an-entity-ref; "), - ("endtag", "script"), - ]) - s = """""" - self._run_check(s, [ - ("starttag", "script", []), - ("data", " "), - ("endtag", "script"), - ]) + contents = [ + ' ¬-an-entity-ref;', + "", + '

', + 'foo = "";', + 'foo = "";', + 'foo = <\n/script> ', + '', + ('\n//<\\/s\'+\'cript>\');\n//]]>'), + '\n\n', + 'foo = "";', + '', + # these two should be invalid according to the HTML 5 spec, + # section 8.1.2.2 + #'foo = ', + #'foo = ', + ] + elements = ['script', 'style', 'SCRIPT', 'STYLE', 'Script', 'Style'] + for content in contents: + for element in elements: + element_lower = element.lower() + s = '<{element}>{content}'.format(element=element, + content=content) + self._run_check(s, [("starttag", element_lower, []), + ("data", content), + ("endtag", element_lower)]) + def test_entityrefs_in_attributes(self): self._run_check("", [ -- cgit v1.2.1