JS/CSS/Noscript code gets added twice to head on 404/403 pages

Created on 21 November 2019, over 5 years ago
Updated 28 July 2023, over 1 year ago

Problem/Motivation

When you enable the field "Enable JavaScript + CSS + Noscript protection", it injects a bit of code into the head of the document using a KernelEvents::RESPONSE event subscriber. That event gets triggered multiple times on error pages (404 or 403), which is causing the code this module adds to the head to get added multiple times.

Steps to reproduce:

  • Install latest stable version of module
  • Enable "Enable JavaScript + CSS + Noscript protection"
  • Visit a page that does not exists to get a 404 error
  • Inspect the page and see and see two instances of the code added by the module, including the seckit.document_write.js script, seckit.no_body.css, and a noscript tag

Proposed resolution

Check if the code has been added to the head already, and if it has do not add it again

Remaining tasks

reviews needed

User interface changes

N/A

API changes

N/A

Data model changes

N/A

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States averagejoe3000 Swanzey, NH

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