fix junitxml bin_xml_escape: supplementary plane characters incorrectly escaped#14484
Conversation
for more information, see https://pre-commit.ci
| def test_bin_xml_escape_supplementary_plane() -> None: | ||
| assert bin_xml_escape(chr(0x1F600)) == chr(0x1F600) | ||
| assert bin_xml_escape("test_😀") == "test_😀" | ||
| assert bin_xml_escape("test_𠀀") == "test_𠀀" |
There was a problem hiding this comment.
What kinda whitespace is this
We may need to rename the function as we ought to avoid leaving likeness as is
There was a problem hiding this comment.
Good point, I'll fold the supplementary plane checks into the existing test and drop the separate function. Pushing a fix shortly.
…, drop separate function
bluetech
left a comment
There was a problem hiding this comment.
Thanks! Please see my comments.
There was a problem hiding this comment.
Do we need to adjust this comment?
There was a problem hiding this comment.
removed the outdated XXX comments since the test now covers supplementary plane codepoints
| @@ -0,0 +1 @@ | |||
| Fixed ``bin_xml_escape`` in junitxml incorrectly escaping supplementary plane characters (U+10000 and above, including emoji) due to using ``\u`` instead of ``\U`` for the supplementary plane range in the ``illegal_xml_re`` regex. | |||
There was a problem hiding this comment.
Can you rewrite this changelog entry to be user-facing? A user doesn't know what bin_xml_escape is, and don't really care what was causing the bug (can click through to the issue if interested). The entry should describe the problem as the user might see it, in this case invalid escaping for high Unicode codepoints.
There was a problem hiding this comment.
And optionally sign with -- by :user:`EternalRights`
There was a problem hiding this comment.
rewritten to describe the user-visible problem, as suggested
There was a problem hiding this comment.
done, added the signature
| @@ -1122,8 +1122,7 @@ def test_invalid_xml_escape() -> None: | |||
| 0xFFFE, | |||
| 0x0FFFF, | |||
| ) # , 0x110000) | |||
There was a problem hiding this comment.
Why is this entry commented out? Do we need new entries here or in the valid tuple?
There was a problem hiding this comment.
removed the comment — 0x110000 exceeds the max Unicode codepoint so it can't be passed to chr()
…nreachable 0x110000
Backport to 9.0.x: 💚 backport PR created✅ Backport PR branch: Backported as #14532 🤖 @patchback |
…748bb15b9053a791c04783d4d84eba512c7cf79/pr-14484 [PR #14484/4748bb15 backport][9.0.x] fix junitxml bin_xml_escape: supplementary plane characters incorrectly escaped
The
illegal_xml_reregex inbin_xml_escapewas using\u10000-\u10ffffto cover the supplementary plane range, but Python's\uescape only takes 4 hex digits. So\u10000was parsed as\u1000+0and\u10ffffas\u10ff+ff, meaning the entire supplementary plane (U+10000 to U+10FFFF) was missing from the "valid" character set.This caused all supplementary plane characters to be incorrectly escaped in JUnit XML output -- emoji, CJK Extension B-F, mathematical symbols, etc. For example
bin_xml_escape("test_😀")returned"test_#x1F600"instead of"test_😀".The fix: change
\u10000-\u10ffffto\U00010000-\U0010ffff(8-digit unicode escape).Also uncommented the supplementary plane code points in the existing
test_bin_xml_escapetest, and added a dedicatedtest_bin_xml_escape_supplementary_planetest with emoji, CJK Ext B, and musical symbol cases.Closes #14483