You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sampling profiler flamegraph HTML does not escape </script> in embedded profile data #159640
json.dumps() does not escape <, > or /, so any string in the data that contains </script> closes the script element early. The strings come from the profiled program: function qualnames, filenames, and source lines read with linecache. When you replay a binary profile (.bin), all of them come from the file itself.
The result is a broken report, and the text after </script> gets parsed as HTML. For example, a function whose qualname is
</script><script>alert(1)</script><script>//
produces a flamegraph where alert(1) runs as a separate script. U+2028/U+2029 in the data can also cause trouble, because older JavaScript engines treat them as line terminators.
This is new in 3.15. 3.14 has no flamegraph exporter.
Proposed fix: after json.dumps(), replace <, >, &, U+2028 and U+2029 with their \uXXXX escapes. These characters can only appear inside JSON string values, so the change is lossless (JSON.parse/the JS literal still gives the original text).
Activity
eendebakpt commentedon Oct 18, 2026
Duplicate of #153840 (or at least overlapping).