Skip to content

gh-153840: Escape special characters in flamegraph function names - #153841

Merged
pablogsal merged 7 commits into
python:mainfrom
tonghuaroot:flamegraph-escape-funcname
Nov 24, 2026
Merged

pablogsal merged 7 commits into
python:mainfrom
tonghuaroot:flamegraph-escape-funcname

Conversation

@tonghuaroot

@tonghuaroot tonghuaroot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Escape <, >, & as < etc. in the embedded JSON blob to prevent </script> breakout, and wrap the tooltip function name with the existing escapeHtml() helper. The sibling heatmap exporter and the flamegraph's own displayName already escape; the function name was missed.

@eendebakpt

Copy link
Copy Markdown
Contributor

Looks ok. Can you add tests?

@tonghuaroot

Copy link
Copy Markdown
Contributor Author

Added a test that verifies </script> in a function name does not appear unescaped in the output.

A single-frame stack yields an empty export, so the escaping was never
exercised. Assert the export succeeded.
@tonghuaroot

Copy link
Copy Markdown
Contributor Author

Done in bfe1755: added & to the payload (</script><b>&) — it's escaped to \\u0026.

@pablogsal pablogsal added the needs backport to 3.15 bugs and security fixes label Nov 24, 2026

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for covering the tooltip case!

@pablogsal
pablogsal merged commit 2aa6d1d into python:main Nov 24, 2026
56 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @tonghuaroot for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Nov 24, 2026

Copy link
Copy Markdown

GH-162544 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants