Views field rewrite replacement subtoken yields double encoded HTML entities

Created on 28 February 2017, over 8 years ago
Updated 11 March 2024, over 1 year ago

Problem/Motivation

When a view field has "Override the output of this field with custom text" checked and the rewrite "Text" field includes a sub-token type replacement pattern (which is added by \Drupal\views\Plugin\views\field\EntityField::addSelfTokens()), special characters in the value of that pattern get double encoded. For instance, if the pattern is a title field such as {{ title__value }} with the value "Q&A", the field is ultimately rendered as Q&A, so the end user sees "Q&A" displayed in their browser.

Steps to reproduce

- Create a new content type with image reference field.
- Enable Alt and Title fields for the image.
- Create a content of the newly created content type.
- Provide Image Alt and Title text with some special char like '&'.
- Create a view for this content type with Fields style.
- Add image filed and rewrite the output of this filed to show only the title of the image.
- Check the output, the special char will be shown as encoded entity.

Proposed resolution

Stop encoding the replaced field value in Drupal\views\Plugin\views\field\EntityField::addSelfTokens(), since the value is encoded later in a call to \Drupal\views\Plugin\views\PluginBase::viewsTokenReplace().

Remaining tasks

User interface changes

NA

API changes

NA

Data model changes

NA

Release notes snippet

Views field rewrite replacement subtoken yields double encoded HTML entities

🐛 Bug report
Status

Fixed

Version

10.3

Component
Views 

Last updated about 5 hours ago

Created by

🇮🇳India adhariwal Jaipur

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

Merge Requests

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