Disabling scripts with categories does not work

Created on 25 October 2022, about 2 years ago
Updated 15 October 2023, about 1 year ago

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

  1. Use "Opt-in with categories" as consent method.
  2. Create a new category
  3. Look up the path of a script that should be disabled, unless consent
    for the category is given.
  4. 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.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany lukas_w

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024