Skip to content

python-markdown: fix html.parser incompatibility with Python 3.12.14 - #18780

Open
kgodara912 wants to merge 1 commit into
3.0-devfrom
kgodara/3.0-dev/python-markdown_fix
Open

python-markdown: fix html.parser incompatibility with Python 3.12.14#18780
kgodara912 wants to merge 1 commit into
3.0-devfrom
kgodara/3.0-dev/python-markdown_fix

Conversation

@kgodara912

@kgodara912 kgodara912 commented Sep 10, 2026

Copy link
Copy Markdown

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

, so the block is wrapped in

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).

Buddy build

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).
@kgodara912
kgodara912 requested a review from a team as a code owner September 10, 2026 04:57
@microsoft-github-policy-service microsoft-github-policy-service Bot added Packaging 3.0-dev PRs Destined for AzureLinux 3.0 labels Sep 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving as per internal discussion with kgodara912

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can consider doing a minor up at 3.10.3 as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.0-dev PRs Destined for AzureLinux 3.0 Packaging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants