File CVE-2025-69534.patch of Package python-Markdown.43069
Index: Markdown-3.5.2/markdown/extensions/md_in_html.py
===================================================================
--- Markdown-3.5.2.orig/markdown/extensions/md_in_html.py
+++ Markdown-3.5.2/markdown/extensions/md_in_html.py
@@ -231,6 +231,10 @@ class HTMLExtractorExtra(HTMLExtractor):
def parse_html_declaration(self, i: int) -> int:
if self.at_line_start() or self.intail or self.mdstack:
+ if self.rawdata[i:i+3] == '<![' and not self.rawdata[i:i+9] == '<![CDATA[':
+ # We have encountered the bug in #1534 (Python bug `gh-77057`).
+ # Provide an override until we drop support for Python < 3.13.
+ return self.parse_bogus_comment(i)
# The same override exists in `HTMLExtractor` without the check
# for `mdstack`. Therefore, use parent of `HTMLExtractor` instead.
return super(HTMLExtractor, self).parse_html_declaration(i)
Index: Markdown-3.5.2/markdown/htmlparser.py
===================================================================
--- Markdown-3.5.2.orig/markdown/htmlparser.py
+++ Markdown-3.5.2/markdown/htmlparser.py
@@ -271,6 +271,10 @@ class HTMLExtractor(htmlparser.HTMLParse
def parse_html_declaration(self, i: int) -> int:
if self.at_line_start() or self.intail:
+ if self.rawdata[i:i+3] == '<![' and not self.rawdata[i:i+9] == '<![CDATA[':
+ # We have encountered the bug in #1534 (Python bug `gh-77057`).
+ # Provide an override until we drop support for Python < 3.13.
+ return self.parse_bogus_comment(i)
return super().parse_html_declaration(i)
# This is not the beginning of a raw block so treat as plain data
# and avoid consuming any tags which may follow (see #1066).
Index: Markdown-3.5.2/tests/test_syntax/blocks/test_html_blocks.py
===================================================================
--- Markdown-3.5.2.orig/tests/test_syntax/blocks/test_html_blocks.py
+++ Markdown-3.5.2/tests/test_syntax/blocks/test_html_blocks.py
@@ -1275,6 +1275,13 @@ class TestHTMLBlocks(TestCase):
)
)
+ def test_not_actually_cdata(self):
+ # Ensure bug reported in #1534 is avoided.
+ self.assertMarkdownRenders(
+ '<![',
+ '<p><![</p>'
+ )
+
def test_raw_cdata_code_span(self):
self.assertMarkdownRenders(
self.dedent(