active-link.js doesn't support query arguments with an ampersand (and other characters))

Created on 24 February 2025, 5 months ago

Problem/Motivation

The data-drupal-link-query attribute contains a JSON string encoded using Json::encode(). This method also encodes <, >, ', &, and ", but these characters aren't encoded by JSON.stringify which results to the links not being marked as active.

Steps to reproduce

  1. Add a main menu link for an existing node, but with a query argument containing an ampersand, e.g. /node/15?value=%26
  2. Place a main menu block in your layout
  3. Browse to the linked node and include the ampersand query argument -> the menu item ain't marked active

Proposed resolution

Change active-link.js to also encode special characters like the ampersand.

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

javascript

Created by

πŸ‡§πŸ‡ͺBelgium matthijs

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024