diff --git a/.spell-dict b/.spell-dict index c82a11dd..c0f0c880 100644 --- a/.spell-dict +++ b/.spell-dict @@ -159,6 +159,7 @@ unescaping unittest unordered unsanitized +unterminated untrusted UTF uTidylib diff --git a/docs/changelog.md b/docs/changelog.md index a6939f91..c99a7c3c 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -17,6 +17,7 @@ See the [Contributing Guide](contributing.md) for details. * Update serializer to be non-recursive (#1644). * Improve ancestor handling in the inline `Treeprocessor` (#1646). * Fix issue where inline HTML attributes were rejected if they had `<` or `>` in the attribute (#1647). +* Fix issue where an unterminated end tag (` int: # pragma: no cover # Treat `` as normal data as it is not a real tag. diff --git a/tests/test_syntax/blocks/test_html_blocks.py b/tests/test_syntax/blocks/test_html_blocks.py index ecc10f45..1f2f8773 100644 --- a/tests/test_syntax/blocks/test_html_blocks.py +++ b/tests/test_syntax/blocks/test_html_blocks.py @@ -1787,3 +1787,60 @@ def test_unclosed_endtag(self): ''' ) ) + + def test_unterminated_endtag_in_code_span(self): + """Ensure an unterminated end tag does not swallow the remaining content.""" + + # https://github.com/Python-Markdown/markdown/issues/1651 + self.assertMarkdownRenders( + 'Run `cmd 2Run cmd 2</dev/null here.

+

This paragraph should not disappear.

+ ''' + ) + ) + + def test_additional_tail_cases(self): + """Ensure various tail cases survive.""" + + # https://github.com/Python-Markdown/markdown/issues/1651 + self.assertMarkdownRenders( + self.dedent( + """ + ` q + + ` q + + ` q + + `` z + """ + ), + self.dedent( + """ +

</dev z > q

+

</ab c z

+

</dev/ > q

+

</dev/null z > q

+

</ab c> z

+ """ + ) + ) + + def test_unterminated_endtag(self): + """Ensure an unterminated end tag is treated as text.""" + + # https://github.com/Python-Markdown/markdown/issues/1651 + self.assertMarkdownRenders( + 'foo foo </bar

+

baz

+ ''' + ) + )