Problem/Motivation
Disabling scripts assigned to specific category does not work. I want to
disable the script of a module and allow the script, if the user consents to a
specific category. Therefore I put something like
examplecat:sites/all/modules/example/example.js into the "Disable
JavaScripts" textbox. However, the script still gets loaded even if the user
does not consent to the specific category.
Steps to reproduce
- Use "Opt-in with categories" as consent method.
- Create a new category
- Look up the path of a script that should be disabled, unless consent
for the category is given. - Load a page on which the script is loaded and do not give consent to
the above category. The script will still get executed.
Proposed resolution
There is a bug in eu_cookie_compliance_js_alter(). The code checks, if the
script exists in the array of all scripts. It does so by comparing the lines
from the "Disable JavaScripts" text area with the path of the attached
javascript files before removing the category (and behavior) from the input
lines. The correct thing would be to strip the category and behavior from the
line, before comparing.
A patch to solve the issue is attached.
| Comment | File | Size | Author |
|---|---|---|---|
| eu_cookie_compliance-fix-disable-scripts-by-category.patch | 1.83 KB | lukas_w |
Comments
Comment #2
svenryen commentedThanks for the report. I'll take a look.
Comment #3
poker10 commentedI can confirm this bug, we have are experiencing it. As mentioned in the IS, the problem is that the
array_key_existscompares the script path with the JS array before the category is removed:So instead of looking for
sites/all/modules/example/example.jsit will look forexamplecat:sites/all/modules/example/example.jsand this will not be found in the JS array and thus not unset.Thanks for working on this! Should this be Needs review?
Comment #5
svenryen commentedThanks for the patch and the RTBC.