Use of inline script is not compatible with a content-security policy

Created on 31 July 2024, 4 months ago

Problem/Motivation

The default `navigation.html.twig` has this in the footer

<script>
  if (localStorage.getItem('Drupal.navigation.sidebarExpanded') !== 'false' && (window.matchMedia('(min-width: 1024px)').matches)) {
    document.documentElement.setAttribute('data-admin-toolbar', 'expanded');
  }
</script>

This is not compatible with a content security policy that prevents unsafe-inline

Steps to reproduce

Enable CSP (e.g use CSP module or seckit module or nginx rules)
Login and see error in page.

Proposed resolution

Move the script to a file and use attach_library.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Navigation 

Last updated about 7 hours ago

No maintainer
Created by

🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024