- Issue created by @xopoc
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.
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"
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]);
Create and test a patch
Active
2.0
Code