Repository navigation
Escape invalid XML characters in JUnit property names - #15397
ashutosh8021 wants to merge 2 commits into
Conversation
Co-authored-by: OpenAI Codex <[email protected]>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Co-authored-by: OpenAI Codex <[email protected]>
chrikrah
left a comment
There was a problem hiding this comment.
On base, a NUL in a record_property name produces a report ElementTree cannot parse. On 812b650 the name comes out as na#x00me, so the property is renamed instead of rejected, the same as the value path already does. As far as I can test it, the fix is right.
# exported trees of fc9a7ef (base) and 812b650 (head), Python 3.12.3
# test_p.py: record_property("na\x00me", "v")
$ pytest -q --junitxml=out.xml test_p.py; grep '<property' out.xml; python -c "ET.parse('out.xml')"
base: <property name="na^@me" value="v" /> ParseError: not well-formed (invalid token)
head: <property name="na#x00me" value="v" /> parses
$ pytest -q -n 4 testing/test_junitxml.py
160 passed # head
6 failed, 154 passed # junitxml.py from base, tests kept
# not run: the rest of testing/, mypy
non-blocking: add_attribute still writes str(name) unescaped. record_xml_attribute is experimental, so leaving it out seems fine to me; is that the intent?
Property values in JUnit XML are escaped for invalid XML characters, but property names are not. A NUL in a name produces an unreadable report, and a lone surrogate crashes report writing. This applies the existing escaping helper to names for both
record_propertyandrecord_testsuite_property.The tests exercise both fixtures, xUnit 1/2 as supported, invalid characters, and valid Unicode/XML-special characters. Six regression cases fail without the fix; all 160 JUnit XML tests and 24 report tests pass with it. Applicable pre-commit checks, including mypy, pass.
AI disclosure: OpenAI Codex generated the patch, regression tests, and this description. The commit includes AI attribution. The changelog fragment is included.