-
Notifications
You must be signed in to change notification settings - Fork 342
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
Strict CSP issue with onclick #3431
Comments
Hello @ganeddact, I agree that Inline 'onclicks' are generally bad practices and should be replaced by event handlers. I will try to add some fixes for these. But what is really strange for me is that you pointed out that after clicking on one checkbox of the multi-select filter attribute in a category page, no filtering applies, and you see the Console log report "Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src." I could not reproduce this on my test environment with fresh Magento 2.4.6-p8 EE and ES 2.11.9.2. I don't see errors in the Console log report, and the filters that I select are applied. Therefore, I'm not sure that the not applying filters issue is linked to using inline 'onclicks', especially when it targets smth with directive: "script-src.", of course I could be wrong. And I just want to know if there are no other things that could effect on this. Maybe you could add more details about your environment and your issue (attributes configuration, etc.), screenshots are welcome, which help to understand where exactly the problem is described by your issue. BR, |
…ion to bind the click events
Hi @vahonc , thanks for your reply.
With default CSP rules that ship with Magento, it would not show up and in fact in your test did not emerge. But if a store is set up for stricter content security policies, this may happen. |
@ganeddact, thanks for this clarification. Could you test my fix on your environment? I will test it with your additional info on my side also. BR, |
I've applied your change and it works like a charm |
Preconditions
Apply a strict CSP, not allowing inline event handlers
Magento Version : 2.4.6-p8
ElasticSuite Version : 2.11.9.2
Environment : developer
Third party modules :
Steps to reproduce
Expected result
Actual result
Looks like in vendor/smile/elasticsuite/src/module-elasticsuite-catalog/view/frontend/web/template/attribute-filter.html on line 15 there is an onclick event that does not sit well with this strict CSP.
Unrelated to the above, there is another one in line 28 in vendor/smile/elasticsuite/src/module-elasticsuite-catalog/view/frontend/templates/layer/filter/default.phtml
Inline onclicks are generally considered bad practice, and should be replaced by event handlers.
The text was updated successfully, but these errors were encountered: