Repository navigation
feat: add Python typing stubs, strict mypy CI, and parser security/conformance fixes - #24
Merged
Merged
Conversation
…urity/conformance fixes
…ar refs, and add XMLID
…ulti-colon QNames
github-actions Bot
pushed a commit
that referenced
this pull request
Oct 27, 2026
# [1.2.0](v1.1.1...v1.2.0) (2026-10-27) ### Features * add Python typing stubs, strict mypy CI, and parser security/conformance fixes ([#24](#24)) ([5506fa1](5506fa1))
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.
Summary
Closes #20.
1. Strict Python Typing (
mypy --strict) & Google Style Enforcement (ruff)python/safexml/_safexml.pyiPEP 561 stub file for the compiled Rust PyO3 extension (parse_xmlandversion).python/safexml/__init__.py,python/safexml/common.py,python/safexml/ElementTree.py,python/safexml/minidom.py, andpython/safexml/sax.py.ruffinpyproject.tomlto enforce Google Python Style Guide conventions and Google-style docstrings (convention = "google",D,ANN,C4,PT,RET,RUF,docstring-code-format = true) and documented all public classes, methods, and functions.mypy --strict python/safexmlin.github/workflows/ci.ymlandtests/test_extended_compatibility.py.2. 100% Code Coverage for Both Python and Rust (Enforced in CI)
303 Stmts, 0 Miss, 54 Branch, 0 BrPart, 100%), enforced viapytest --cov=safexml --cov-branch --cov-fail-under=100.2,411 Lines, 0 Miss, 101 Functions, 0 Miss, 100.00%) acrosssrc/doctype.rs,src/parser.rs, andsrc/python.rs, enforced in.github/workflows/ci.ymlviallvm-cov.3. Security & Conformance Bug Fixes (Broad Bug Sweeps)
src/parser.rs): Enforced null-byte checks,is_valid_xml_qname,max_name_size,max_attribute_size,max_attributes,max_text_size,<rejection, character validation, whitespace normalization, and entity unescaping on<!ATTLIST>default attributes.<!NOTATION>and Parameter Entity (%pe;) Bypass in DTD (src/doctype.rs,src/parser.rs): Parsed<!NOTATION>declarations and%pe;references in internal subsets; enforcedExternalReferenceForbiddenandEntitiesForbidden.src/parser.rs): Fixedis_valid_xml_qnameto reject QNames containing multiple colons (e.g.<p:a:b/>).+Sign & Malformed&...;in Attributes (src/parser.rs): Rejected&#+65;/&#x+41;per W3C XML 1.0[66] CharRefand rejected malformed attribute entity names before checkingforbid_entities.src/parser.rs): Enforcedmax_comment_sizeonEvent::PIpayloads and split PI target using strict XML whitespace (is_xml_whitespace).XMLParser.feed()Input Size Limit (python/safexml/ElementTree.py): Enforcedmax_input_sizeimmediately duringfeed()before buffering unbounded chunks in memory, and prevented post-close()buffer accumulation.python/safexml/ElementTree.py,python/safexml/minidom.py,python/safexml/sax.py): Converted recursive tree traversals inXMLParser,minidom._element_to_dom, andsax._replay_elementto explicit iterative stacks so trees withmax_depth > 1000never raiseRecursionError.forbid_dtd/forbid_entities/forbid_externalParity Across All Entrypoints (python/safexml/__init__.py,python/safexml/ElementTree.py): Added missing security parameters tosafexml.parse,safexml.fromstring,ElementTree.iterparse, andXMLParser.