python-markdown: fix html.parser incompatibility with Python 3.12.14 - #18780
Open
kgodara912 wants to merge 1 commit into
Open
python-markdown: fix html.parser incompatibility with Python 3.12.14#18780kgodara912 wants to merge 1 commit into
kgodara912 wants to merge 1 commit into
Conversation
CPython 3.12.14 backported the 3.14-era html.parser rewrite (locatetagend,
new attrfind_tolerant, commentclose '--!?>'), which 3.12.9 did not have.
Under the new parser an unterminated tag in a code span, e.g. `<div`, is
buffered as an incomplete start tag and swallows the following real <div>,
so the block is wrapped in <p> instead of being emitted as raw HTML. This
broke 4 tests:
test_syntax.blocks.test_html_blocks.TestHTMLBlocks
- test_raw_unclosed_tag_in_code_span
- test_raw_unclosed_tag_in_code_span_space
test_syntax.extensions.test_md_in_html.TestDefaultwMdInHTML
- test_raw_unclosed_tag_in_code_span
- test_raw_unclosed_tag_in_code_span_space
Backport the upstream fix (commit 15346cd, PR Python-Markdown/markdown#1548,
fixes #1547, released in 3.9.0), which monkeypatches htmlparser.locatetagend
to exclude backticks from tag names, attribute names and bare values.
Also drop the existing prep section sed test skips for
test_raw_missing_close_bracket and test_unclosed_comment_. Those were only
needed for the partial html.parser CVE backports in python3-3.12.9;
markdown 3.8.2 already handles the complete parser now shipped in 3.12.14.
Verified against the new parser: 1010 tests, OK (skipped=64).
Muhammad Falak R Wani (mfrw)
left a comment
Member
There was a problem hiding this comment.
I think we might need more eyeballs on this change.
| LICENSE.md > LICENSE.html | ||
|
|
||
| %check | ||
| # Skip test_raw_missing_close_bracket and test_unclosed_comment_ (Python 3.12 html.parser changes) |
Copilot started reviewing on behalf of
Muhammad Falak R Wani (mfrw)
September 10, 2026 07:58
View session
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The patch matches upstream commit 15346cd and the packaging changes are complete and consistent.
Pull request overview
Backports the upstream Python-Markdown fix for Python 3.12.14’s updated HTML parser.
Changes:
- Adds the upstream incomplete-tag parsing patch.
- Re-enables previously skipped parser tests.
- Increments the package release.
File summaries
| File | Description |
|---|---|
python-markdown.spec |
Applies the patch and restores tests. |
0002-Fix-handling-of-incomplete-HTML-tags-in-code-spans.patch |
Backports the upstream parser fix. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Muhammad Falak R Wani (mfrw)
approved these changes
Sep 10, 2026
Muhammad Falak R Wani (mfrw)
left a comment
Member
There was a problem hiding this comment.
Approving as per internal discussion with kgodara912
Kanishk Bansal (Kanishk-Bansal)
left a comment
There was a problem hiding this comment.
You can consider doing a minor up at 3.10.3 as well
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CPython 3.12.14 backported the 3.14-era html.parser rewrite (locatetagend, new attrfind_tolerant, commentclose '--!?>'), which 3.12.9 did not have. Under the new parser an unterminated tag in a code span, e.g.
<div, is buffered as an incomplete start tag and swallows the following realinstead of being emitted as raw HTML. This broke 4 tests:
test_syntax.blocks.test_html_blocks.TestHTMLBlocks
- test_raw_unclosed_tag_in_code_span
- test_raw_unclosed_tag_in_code_span_space test_syntax.extensions.test_md_in_html.TestDefaultwMdInHTML
- test_raw_unclosed_tag_in_code_span
- test_raw_unclosed_tag_in_code_span_space
Backport the upstream fix (commit 15346cd, PR Python-Markdown/markdown#1548, fixes #1547, released in 3.9.0), which monkeypatches htmlparser.locatetagend to exclude backticks from tag names, attribute names and bare values.
Also drop the existing prep section sed test skips for test_raw_missing_close_bracket and test_unclosed_comment_. Those were only needed for the partial html.parser CVE backports in python3-3.12.9; markdown 3.8.2 already handles the complete parser now shipped in 3.12.14.
Verified against the new parser: 1010 tests, OK (skipped=64).
Buddy build