Added CSP support for inline scripts.#108
Open
hostep wants to merge 1 commit intotrustpilot:masterfrom
Open
Conversation
Open
|
@hostep given how unreliable TP are at responding here, I may fork this and get all these recent PRs into it. |
|
@ssx, did you fork and merge those PRs? |
it's on my list to do this week! |
|
Great :)
*Itay Raz*
054-4635797
***@***.***
studioraz.co.il
…On Mon, 14 Jul 2025 at 9:46 Scott Robinson ***@***.***> wrote:
*ssx* left a comment (trustpilot/plugin-magento2#108)
<#108 (comment)>
@ssx <https://github.com/ssx>, did you fork and merge those PRs?
it's on my list to do this week!
—
Reply to this email directly, view it on GitHub
<#108 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADYNDMUJT442A6WMVHNVXD3ING5PAVCNFSM6AAAAACAZQY6VWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTANRYGA2DCMJYGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
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.
Ticket 🎟
#107
What⁉️
Adds CSP (Content-Security-Policy) support to the frontend inline scripts in this module, so those aren't being blocked on the checkout in modern Magento versions.
Additional cleanup:
Why⁉️
Magento started blocking inline javascript scripts many months ago on the checkout.
How⁉️
Using the
SecureHtmlRenderer(introduced in Magento 2.4.0) we can output the inline javascript with nonces so they no longer violate the CSP policies.I took extra precaution because the
composer.jsonfile of this module allows the module to still be installed on Magento versions older then 2.4.0, so I'm first checking ifSecureHtmlRendererexists before trying to use it so the module should (untested) be backwards compatible still with older versions of Magento as well.How to review and test 📱
Open a modern Magento shop with this module installed, especially the checkout and see if no inline scripts are being blocked anymore after changes from this PR. And all scripts keep working as expected.
Open an older version of a Magento shop (2.3.7-p4 for example) with this module installed and see if all scripts keep working as expected.
Checklist ✅