diff options
author | Waylan Limberg <waylan.limberg@icloud.com> | 2020-10-12 14:17:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-12 14:17:03 -0400 |
commit | 5fdf7d47aa90a0983fa356b577a2ff5e16e68147 (patch) | |
tree | b0bcd2b3cdb1e26b7fafc00c4f044cffebf93656 /tests | |
parent | e02ed390666930ce8640d4cebcac51059e9a34d8 (diff) | |
download | python-markdown-5fdf7d47aa90a0983fa356b577a2ff5e16e68147.tar.gz |
Correctly parse raw `script` and `style` tags. (#1038)
* Ensure unclosed script tags are parsed correctly by providing a workaround for https://bugs.python.org/issue41989.
* Avoid cdata_mode outside of HTML blocks, such as in inline code spans.
Fixes #1036.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_syntax/blocks/test_html_blocks.py | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/test_syntax/blocks/test_html_blocks.py b/tests/test_syntax/blocks/test_html_blocks.py index 0a2092d..3fea766 100644 --- a/tests/test_syntax/blocks/test_html_blocks.py +++ b/tests/test_syntax/blocks/test_html_blocks.py @@ -1317,3 +1317,88 @@ class TestHTMLBlocks(TestCase): """ ) ) + + def test_script_tags(self): + self.assertMarkdownRenders( + self.dedent( + """ + <script> + *random stuff* <div> & + </script> + + <style> + **more stuff** + </style> + """ + ), + self.dedent( + """ + <script> + *random stuff* <div> & + </script> + + <style> + **more stuff** + </style> + """ + ) + ) + + def test_unclosed_script_tag(self): + # Ensure we have a working fix for https://bugs.python.org/issue41989 + self.assertMarkdownRenders( + self.dedent( + """ + <script> + *random stuff* <div> & + + Still part of the *script* tag + """ + ), + self.dedent( + """ + <script> + *random stuff* <div> & + + Still part of the *script* tag + """ + ) + ) + + def test_inline_script_tags(self): + # Ensure inline script tags doesn't cause the parser to eat content (see #1036). + self.assertMarkdownRenders( + self.dedent( + """ + Text `<script>` more *text*. + + <div> + *foo* + </div> + + <div> + + bar + + </div> + + A new paragraph with a closing `</script>` tag. + """ + ), + self.dedent( + """ + <p>Text <code><script></code> more <em>text</em>.</p> + <div> + *foo* + </div> + + <div> + + bar + + </div> + + <p>A new paragraph with a closing <code></script></code> tag.</p> + """ + ) + ) |