Context Breadcrumb does not respect special characters in the token values

Created on 6 November 2024, 16 days ago

Problem/Motivation

The Context Breadcrumb module does not correctly handle special characters in token values, causing them to be HTML-encoded in the breadcrumb output. This results in an incorrect display of the breadcrumb on the site, as special characters like & in tokenized values are shown as &, affecting user experience.
This issue specifically occurs when using tokens in breadcrumb titles, such as [site:name], which are rendered with HTML entities instead of the intended characters.

Steps to reproduce

Install drupal 10.2.7 + context_breadcrumbs 2.0.10
On Configuration -> Basig site settings pages add a Site name - "Foo & bar" and Save
Then go to Structure -> Context and add a new context
Fill the Label field with "Test"
Do not add any condition to simplify testing
Add a "Breadcrumb" reaction
Fill the title with a "[site:name]" token, "/" for the Url field and select "Yes" in the Token dropdown and save
Go to the home page

Expected: Breadcrumb is "Foo & bar"

Actual: Breadcrumb is "Foo & bar"

Proposed resolution

The issue occurs in the Drupal\context_breadcrumb\Breadcrumb\ContextBreadcrumbBuilder::renderData() method when the token is rendered.
A proposed solution is replace

$this->token->replace($title, $data, ['clear' => TRUE]);

with

$this->token->replacePlain($title, $data, ['clear' => TRUE]);

Remaining tasks

Create and test a patch

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States xopoc

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

Comments & Activities

Production build 0.71.5 2024