-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Profiler] Fix dump makes toolbar disappear #27189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you @ogizanagi. |
This PR was merged into the 4.1 branch. Discussion ---------- [Profiler] Fix dump makes toolbar disappear | Q | A | ------------- | --- | Branch? | 4.1 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #27180 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A Don't know if there is a better solution than executing eval on the global scope. For ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval > If you use the eval function indirectly, by invoking it via a reference other than eval, as of ECMAScript 5 it works in the global scope rather than the local scope. This means, for instance, that function declarations create global functions, and that the code being evaluated doesn't have access to local variables within the scope where it's being called. Commits ------- 0cd51ae [Profiler] Fix dump makes toolbar disappear
/* Evaluate in global scope scripts embedded inside the toolbar */ | ||
eval.call({}, ([].slice.call(el.querySelectorAll('script')).map(function (script) { | ||
return script.firstChild.nodeValue; | ||
}).join('\n'))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should join them using ;\n
to avoid issues in case of having a script without a final semi-colon. The ASI rules might not always end a statement on a newline char.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Fixed in 0998710
… toolbar (stof) This PR was merged into the 4.1 branch. Discussion ---------- Avoid calling eval when there is no script embedded in the toolbar | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27583 | License | MIT | Doc PR | n/a #27189 changed the way embedded scripts were eval'd for the toolbar. But it also refactored the code in a way triggering `eval` all the time, even when there is no embedded script, which was reported several times as an issue with CSP. While the debug panel (showing dumps) still requires having `unsafe-eval` in the CSP header (due to embedding scripts that we eval), this PR reverts back to the behavior of Symfony 4.0 and older, where only toolbars actually embedding scripts have this CSP compat issue. Commits ------- a0f78a5 Avoid calling eval when there is no script embedded in the toolbar
Don't know if there is a better solution than executing eval on the global scope.
For ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval