Needs review
Project:
Entity Embed
Version:
8.x-1.6
Component:
CKEditor integration
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Jan 2024 at 01:50 UTC
Updated:
24 Jan 2025 at 04:35 UTC
Jump to comment: Most recent
Comments
Comment #2
codesmithI got this working by creating a custom Twig filter for html_entity_decode and then adding it to a filter-caption.html.twig template override. Bit clunky though. Looks like Drupal Media can handle HTML in captions just fine.
Comment #3
ericpughI had the same problem after moving from Drupal 9.5 to 10.2.
I can't figure out why this abruptly changed the way it rendered (some Twig 3 change?) but it's happening because the value is passed through escapeValue.
You could always remove the validate from the element, but of course... that's probably a bad idea.
Comment #4
odenscComment #5
odenscThe source of this issue appears to be that the
data-captionvalue is getting double-encoded, e.g.&<strong&>instead of<strong>as it used to be with CKEditor 4.This is because the dataDowncast step in the CKEditor 5 plugin is encoding the already-encoded
data-captionvalue. Removing the escapeValue validation function as @ericpugh mentions should fix this, since it's handled by CKEditor already like Drupal's Core media module.Comment #6
odenscI've created an MR which removes the
escapeValuefunction and fixes the issue.There is an existing test for HTML in captions, but it didn't catch this issue since it's just testing a raw
<drupal-entity>tag that has a correctly encodeddata-captionattribute. This issue only manifests if the caption is set via the entity embed dialog.I'm not familiar enough with the tests here to know how to set up something that would cover this case, since it would need to interface with both the dialog and the CKEditor integration at the same time, and right now there only appear to be separate tests for each.
Comment #7
odensc