-
-
Notifications
You must be signed in to change notification settings - Fork 416
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
Content security policies not currently supported #166
Comments
Hi @thomasnaude , mhm, this is weird since the script already copies all existing attributes over to the new script: cookieconsent/src/cookieconsent.js Lines 1397 to 1405 in 7a96e1b
|
Hi @orestbida Thanks for the quick reply. In Chrome, reading a nonce attribute will return a blank. We need to call
I guess this must be browser dependent as the suggested GTM implementation is calling both methods (see original post). |
Oh, I see! In this case — instead of adding specific code just for the (function(destination, source){
var attributes = source.attributes;
var len = attributes.length;
for(var i=0; i<len; i++){
var attr_name = attributes[i].nodeName;
destination.setAttribute(attr_name , source[attr_name] || source.getAttribute(attr_name));
}
})(fresh_script, curr_script); Can you verify that this fixes the issue? |
I just tested this and it works like a charm ! |
Problem
The use of a content security policy is not currently supported when using the
page_scripts
option.The CSP will prevent the new script from being inserted
Solution
Add a nonce attribute (if it exists) to the fresh script before adding it to the dom.
Google Tag Manager provides an example of how they do it : https://developers.google.com/tag-platform/tag-manager/web/csp
This would be implemented by adding the code below before loading the scripts :
I am happy to provide a PR if you wish
The text was updated successfully, but these errors were encountered: