Issue with embedded entities and Html::decodeEntities

Created on 21 February 2025, 3 days ago

Problem/Motivation

When using the entity_embed module alongside this module, WYSIWYG embedded entities that are returned from Google Cloud translate have the

Directly after receiving translation from Google.

<drupal-entity data-entity-type="media" data-entity-uuid="bdf34a77-8019-41f6-8234-9ed11370e3cf" data-embed-button="image_bundle" data-entity-embed-display="entity_reference:entity_reference_entity_view" data-entity-embed-display-settings="{&quot;view_mode&quot;:&quot;gallery_full_width_no_thumbnail&quot;}"></drupal-entity>

Directly after running the text through Html::decodeEntities, the html entities are decoded as expected.

<drupal-entity data-entity-type="media" data-entity-uuid="bdf34a77-8019-41f6-8234-9ed11370e3cf" data-embed-button="image_bundle" data-entity-embed-display="entity_reference:entity_reference_entity_view" data-entity-embed-display-settings="{"view_mode":"gallery_full_width_no_thumbnail"}"></drupal-entity>

Now, when you go to view the translation on the node page the FilterHtml is removing it with the Xss:filter even though it is one of the allowed html tags. The end result is that it is like this, and the display-settings are stripped out, so the images render much small than the default translation that hasn't passed through Google translate.

<drupal-entity data-entity-type="media" data-entity-uuid="bdf34a77-8019-41f6-8234-9ed11370e3cf" data-embed-button="image_bundle" data-entity-embed-display="entity_reference:entity_reference_entity_view"></drupal-entity>

I'm currently working around this by re-encoding just the display-settings but I wonder if there is a fix we can apply in the module instead?

Steps to reproduce

* Install entity_embed.
* Set some display settings I guess.
* Use this module to request translation of some content using an embed inside a wysiwyg.
* Notice that the display-settings data attribute it stripped out.

Proposed resolution

Unsure of the best solution. Open to suggestions.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

achap 🇦🇺

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

Comments & Activities

Production build 0.71.5 2024