Skip to content

[3.15] gh-156812: Check structural rules when serializing in xml.dom.minidom (GH-161830) - #162680

Merged
serhiy-storchaka merged 1 commit into
python:3.15from
serhiy-storchaka:backport-79494e2-3.15
Nov 26, 2026
Merged

serhiy-storchaka merged 1 commit into
python:3.15from
serhiy-storchaka:backport-79494e2-3.15

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

(cherry picked from commit 79494e2)

Manual backport: the cherry-pick conflicted because _quote_literal() is inserted above _check_name(), which only exists on main.

_check_name() is therefore added here too, because ProcessingInstruction.writexml() calls it and xml.is_valid_name() is available in 3.15. Everything else is identical to the original commit.

🤖 Generated with Claude Code

…l.dom.minidom (pythonGH-161830)

Only the structure is checked, not the characters.

A comment ending with '-' was fused with the closing '-->' into '--->'.
A processing instruction was not checked at all: '?>' in the data silently
closed it, and the reserved target 'xml' produced a document which cannot
be parsed.  The identifiers of the document type declaration were
interpolated into single quotes without checks, so an identifier containing
a quote or other illegal character produced XML which is not well-formed,
and a public identifier without a system identifier produced the literal
'None'.
(cherry picked from commit 79494e2)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@read-the-docs-community

Copy link
Copy Markdown

@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) November 26, 2026 11:44
@serhiy-storchaka
serhiy-storchaka merged commit 541cbc9 into python:3.15 Nov 26, 2026
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant