fix(trace_timeline): escape invalid XML characters in present titles #28352

Open
GalaxyGamingFR wants to merge 1 commit from upstream-pr/28352 into main
GalaxyGamingFR commented 2026-11-30 09:05:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by GalaxyGamingFR on 2026-11-30T09:05:59Z.


What

Slice and thread labels go through escape_text(), which replaces characters XML does not allow with U+FFFD, but present-marker titles used only html.escape. A present string with a control character (for example "a" in args.present) put the raw character into the SVG, and the page's SVG no longer parsed as XML. Present titles now use escape_text() too.

The new test writes such a present event and checks the U+FFFD title and that the SVG parses with xml.etree.ElementTree.

Tested

Windows 11, Python 3.12. The new test fails on main with AssertionError: '<title>Present a� at 0.005 ms</title>' not found and passes with the fix. python tools/tests/test_trace_timeline.py (33 (1 skipped) tests) and python tools/check_conventions.py --base origin/main pass. No open pull request touches tools/trace_timeline.py.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Present marker titles now handle characters that are invalid in XML, replacing them so the exported SVG remains valid. This prevents malformed output when trace event labels contain unsupported characters and helps ensure the timeline can be opened by SVG-compatible tools. Title text now follows the same safe rendering behavior as other text in the timeline.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5562229267 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28352). Originally posted by [GalaxyGamingFR](https://github.com/GalaxyGamingFR) on 2026-11-30T09:05:59Z. --- ### What Slice and thread labels go through `escape_text()`, which replaces characters XML does not allow with U+FFFD, but present-marker titles used only `html.escape`. A present string with a control character (for example `"a"` in `args.present`) put the raw character into the SVG, and the page's SVG no longer parsed as XML. Present titles now use `escape_text()` too. The new test writes such a present event and checks the U+FFFD title and that the SVG parses with `xml.etree.ElementTree`. ### Tested Windows 11, Python 3.12. The new test fails on `main` with `AssertionError: '<title>Present a� at 0.005 ms</title>' not found` and passes with the fix. `python tools/tests/test_trace_timeline.py` (33 (1 skipped) tests) and `python tools/check_conventions.py --base origin/main` pass. No open pull request touches `tools/trace_timeline.py`. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Present marker titles now handle characters that are invalid in XML, replacing them so the exported SVG remains valid. This prevents malformed output when trace event labels contain unsupported characters and helps ensure the timeline can be opened by SVG-compatible tools. Title text now follows the same safe rendering behavior as other text in the timeline. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-11-30 09:20:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T09:20:32Z.

Review: APPROVED


Reviewed — looks good

The change sanitizes present marker titles with the existing XML-safe escaping helper, and the reviewed source supports merging.

What I ran

Reviewed head 4092ee8a05112fb5ce016791af6b7e567e88320f. No commands or tests were run in this review session.

Results

Check Result Note
Source review passed Both changed files read
Tests not run Author reports the test suite passed

Findings

Blocking

None.

Non-blocking

None.

Not verified

The full contents of both changed files were not read; only the relevant source and test ranges were inspected. Runtime behavior and the author-reported test results were not independently verified. files.json was not available through the review reader, so excluded files were not verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6109537347 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28352#pullrequestreview-6109537347). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-30T09:20:32Z. **Review:** APPROVED --- # Reviewed — looks good The change sanitizes present marker titles with the existing XML-safe escaping helper, and the reviewed source supports merging. ## What I ran Reviewed head `4092ee8a05112fb5ce016791af6b7e567e88320f`. No commands or tests were run in this review session. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Both changed files read | | Tests | not run | Author reports the test suite passed | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The full contents of both changed files were not read; only the relevant source and test ranges were inspected. Runtime behavior and the author-reported test results were not independently verified. `files.json` was not available through the review reader, so excluded files were not verified. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 05:36:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T05:36:24Z.

Review: COMMENTED


All 33 trace-timeline tests passed at dda108ddba. The new CLI case generated HTML from a trace with a NUL in a present name, verified the replacement character in the title, and parsed the resulting SVG as XML. Existing tests for invalid characters in labels also passed.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6164241754 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28352#pullrequestreview-6164241754). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T05:36:24Z. **Review:** COMMENTED --- All 33 trace-timeline tests passed at `dda108ddba`. The new CLI case generated HTML from a trace with a NUL in a present name, verified the replacement character in the title, and parsed the resulting SVG as XML. Existing tests for invalid characters in labels also passed. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/28352:upstream-pr/28352'
git switch 'upstream-pr/28352'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/28352'
git switch 'upstream-pr/28352'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/28352'
git switch 'upstream-pr/28352'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/28352'
git switch 'main'
git merge --squash 'upstream-pr/28352'
git switch 'main'
git merge --ff-only 'upstream-pr/28352'
git switch 'main'
git merge 'upstream-pr/28352'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!28352
No description provided.