Files
b25ab5e76b Align XML backend and canonical libraries with Python 3.15 (#9197)
* Align XML parsing and libraries with Python 3.15

Retain the existing XML backend accounting changes and their explicit registry publication limitation. Preserve canonical XML tests and existing RustPython guards, including multiline marker explanations through update_lib.

Assisted-by: OpenAI Codex:model version unavailable

* Retire proven XML guards and sync canonical consumers

Assisted-by: OpenAI Codex:model version unavailable

* Rebase vendored xml onto 1.4.0

Replace the vendored crate sources with the published xml 1.4.0 archive
and reapply the amplification accounting patch on top of it. The two
lexer hunks that conflicted with the new line-ending normalization are
merged into the 1.4.0 read loop. The patch no longer normalizes CR in
entity values or collapses CRLF in attribute values, because the 1.4.0
lexer and attribute reader already do so.

Update the checksums, recorded upstream commit, archive hash and
provenance notes, and require version 1.4 for the path dependency.

Assisted-by: Claude Code:claude-opus-5-5

* Remove stale SAX external resolver expected failure

Linux and macOS canonical CI both demonstrate that the existing
unsupported-scheme resolver test passes. Retire only its expected-failure
decorator through update_lib, preserving its canonical assertions.
This does not implement external DTD parsing.

AI assistance: dot diagnosed CI, migrated the marker, and reviewed the
source delta and normal-hook validation; the model version is not exposed.

Assisted-by: dot: model version not exposed

---------

Co-authored-by: Jeong YunWon <jeong@youknowone.org>
Co-authored-by: youknowdot <336763669+youknowdot@users.noreply.github.com>
2026-10-27 21:02:59 +09:00

38 lines
1.2 KiB
Python
Vendored

lazy import re as _re
def is_valid_name(name):
"""Test whether a string is a valid element or attribute name."""
# https://www.w3.org/TR/xml/#NT-Name
return _re.fullmatch(
# NameStartChar
'['
':A-Z_a-z'
'\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF'
'\u200C\u200D'
'\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF'
'\uF900-\uFDCF\uFDF0-\uFFFD\U00010000-\U000EFFFF'
']'
# NameChar
'['
r'\-.0-9:A-Z_a-z'
'\xB7'
'\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF'
'\u200C\u200D\u203F\u2040'
'\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF'
'\uF900-\uFDCF\uFDF0-\uFFFD\U00010000-\U000EFFFF'
']*+',
name) is not None
# https://www.w3.org/TR/xml/#charsets
_ILLEGAL_XML_CHAR = (
'['
'\x00-\x08\x0B\x0C\x0E-\x1F' # C0 controls except TAB, CR and LF
'\uD800-\uDFFF' # the surrogate blocks
'\uFFFE\uFFFF' # special Unicode characters
']')
def is_valid_text(data):
"""Test whether a string is a sequence of legal XML 1.0 characters."""
return _re.search(_ILLEGAL_XML_CHAR, data) is None