Repository navigation
Conversation
…usted Types policy (nette#616) Pages that enforce require-trusted-types-for 'script' refuse plain strings at innerHTML, insertAdjacentHTML, script src, and script text, which threw in Debug.init() and left no bar at all. helpers.js, which runs first in all three bundles, creates the policy once per window; without Trusted Types support, or when the page's trusted-types directive doesn't allow the name, the strings pass through unchanged as before.
adrianbj
added a commit
to adrianbj/TracyDebugger
that referenced
this pull request
Oct 26, 2026
…rce Trusted Types (require-trusted-types-for 'script'), by passing Tracy's own markup and scripts through a 'tracy' policy; a marked core patch until nette/tracy#624 is released
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #616.
On a page whose Content-Security-Policy includes
require-trusted-types-for 'script', the browser refuses plain strings atinnerHTML,insertAdjacentHTML, a script'ssrc, and a script's text.Debug.init()throws on its firstinnerHTML, so no bar appears at all.This adds
Tracy.trustedtohelpers.js. It runs first in all three bundles: the bar, the BlueScreen, andDumper::renderAssets(). It creates atracypolicy once per window, and the ten sinks pass their strings through it:bar.js: the panel content, the popup window's body and script, the layer, AJAX panels and rows,loadScript(), andevalScripts()dumper.js:createEl()bluescreen.js:loadAjax()The policy passes everything unchanged. These strings are Tracy's own server-rendered markup, which is already escaped where it needs to be.
Behavior is unchanged when:
trusted-typesdirective doesn't allow thetracyname; strings are passed as before, so a site that restricts policy names needs to addtracyto its listTested with Chrome against the examples on v2.13 (the four JS files are identical to master's), with
require-trusted-types-for 'script'enforced:barDump.php: bar, panels, dump expansion, panel opened in a new windowDebug.init(), no barajax-fetch.php: AJAX row, AJAX error BlueScreendump.phpexception.phpI couldn't run
npm run lintlocally.