The inline CSS and JS output violate standard CSP policies (not allowing unsafe-inline)
And Drupal coding best practices (no inline javascript, keep design separate from the content)
Can the JS and CSS come from libraries instead?
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | eu_cookie_compliance-compatibility-with-content-security-policy-3029549-15.patch | 5.35 KB | svenryen |
Comments
Comment #2
gappleComment #3
svenryen commentedGood point. There's room for some refactoring once all the bug reports have been settled. Thanks for the focus on this.
Comment #4
anybody@gapple: Thank you very much! You're absolutely right! As an expert creating wonderful modules like "ga" - could you perhaps help a bit here with a first implementation or some hints how or where to start?
I guess that would help a lot!
Comment #5
gappleIt looks like there is one place where inline JS and CSS is added to the page: https://git.drupalcode.org/project/eu-cookie-compliance/-/blob/8.x-1.x/e.... I'm unsure why this is done with inline script.
It looks like it should maybe either be converted to load a library and use hook_library_info_alter to update the the files that are included in the library based on the relevant configuration, or it should pass the necessary info via drupalSettings (as is done elsewhere).
Comment #6
svenryen commentedWe won't be doing inline css in 2.x.
Comment #7
svenryen commentedI'm flagging this for 2.x, with possibility for backport to 1.x.
Comment #8
caco_d25 commentedThis patch create and attach JS file instead of using inline JS
Comment #9
svenryen commentedThanks for the patch, @caco_d25.
Do we have to do something similar for css?
Comment #10
gappleWill take a better look at the patch later, but with the snippet being written out to a file I don't see any reason to keep using
$variables['#attached']['html_head'][]instead of defining a library and using$variables['#attached']['library'][].The library will most likely need
{preprocess: false}on the file to ensure it's not aggregated.Comment #11
svenryen commentedComment #12
svenryen commentedI brushed up the patch a bit and fixed some coding style issues. Here's a revised patch.
Comment #13
svenryen commentedComment #14
svenryen commentedIt seems that my patch in #12 is for a different issue, possibly #3208780: Allow config settings to be saved independent of related modules, and got saved with the wrong file name.
I'll take a look at the patch from #8 tomorrow.
Comment #15
svenryen commentedHere's an updated patch.
The EventSubscriber was mistakenly committed in #3236506: Fix PHP Coding Standards for EUCC.
Comment #17
svenryen commented