Bad rendered text caused by double html escape.

Created on 25 April 2023, over 1 year ago

Problem/Motivation

In a label ' instead of ':
Views : filtrer par une vue d'entité référencée
french translation of
Views: Filter by an entity reference view

There is a double Html::escape and & is changed in &.
1) The first in lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php in function fieldSettingsForm,

    foreach (array_keys($selection_plugins) as $selection_group_id) {
      // We only display base plugins (e.g. 'default', 'views', ...) and not
      // entity type specific plugins (e.g. 'default:node', 'default:user',
      // ...).
      if (array_key_exists($selection_group_id, $selection_plugins[$selection_group_id])) {
        $handlers_options[$selection_group_id] = Html::escape($selection_plugins[$selection_group_id][$selection_group_id]['label']);
      }
      elseif (array_key_exists($selection_group_id . ':' . $this->getSetting('target_type'), $selection_plugins[$selection_group_id])) {
        $selection_group_plugin = $selection_group_id . ':' . $this->getSetting('target_type');
        $handlers_options[$selection_group_plugin] = Html::escape($selection_plugins[$selection_group_id][$selection_group_plugin]['base_plugin_label']);
      }
    }

With two lines with Html::escape.

2) The second in lib/Drupal/Core/Template/TwigExtension.php in function escapeFilter,

    if (isset($return)) {
      if ($autoescape && $return instanceof MarkupInterface) {
        return $return;
      }
      // Drupal only supports the HTML escaping strategy, so provide a
      // fallback for other strategies.
      if ($strategy == 'html') {
        return Html::escape($return);
      }

It's not a translation problem since the change of the original label produce the same problem.

Steps to reproduce

- Use an other language like french.
- Create a field of type Entity Reference Revisions.
- Edit the field.
- Into the form Reference type>Reference method see the translation of
Views: Filter by an entity reference view

In fact, put an apostrophe ' in a translation of a label of this form.

Other similarly case:
- Add the module paragraph.
You should have a new enter in the form: Default.
- Put a ' in its translation.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

9.5

Component
Render 

Last updated 7 days ago

Created by

🇫🇷France Chris64 France

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

Comments & Activities

Production build 0.71.5 2024