Problem/Motivation

The label of the Entity Embed icons that contain special characters are double-escaped on CKEditor5:

Embed button label on CKEditor4

CKEditor4:

Embed button label on CKEditor4

Steps to reproduce

  1. On the /admin/config/content/embed/button/manage/node page set a human label containing some special characters (eg. copy this four: “&–×‼️”)
  2. Save the configuration
  3. Visit the setting page one of the text formats where the CKEditor is enabled (eg. /admin/config/content/formats/manage/full_html)
  4. Hover your mouse pointer above the button with the icon “E”
  5. The tooltip appearing should not contain the & string
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Dave Reid created an issue. See original summary.

edmoreta’s picture

Removing the escape from the label has resolved the issue for me. Thanks!

mortona2k’s picture

StatusFileSize
new863 bytes

Here's a patch from the issue fork.

What's next on this?

Balu Ertl made their first commit to this issue’s fork.

baluertl’s picture

Issue summary: View changes
Status: Active » Reviewed & tested by the community
StatusFileSize
new17.91 KB

“What's next on this?”

The content of this patch has been committed (53384f76) earlier to a separate branch by the module maintainer, and now an MR (!40) has been opened for better visibility.

Tested, the patch does fix the escaping of special characters indeed:
Comparison screenshot

dave reid’s picture

I updated this one to mention the browser test added since the first draft. The XSS explanation is already posted on !40 itself, so this comment links to it.

I've rebased !40 onto 8.x-1.x and added tests: a kernel test, DrupalEntityCKEditor5PluginTest, that fails without the fix, and a browser test, CKEditor5IntegrationTest::testButtonLabelIsText(), confirming that a label containing HTML shows as text and can't run script (details in the MR).

A correction to the steps to reproduce: the double-escaped label shows in the editor itself (hover over the embed button while editing content), not on the text format's settings page. That page displays labels correctly, since core's admin UI inserts them as HTML, so DrupalEntityDeriver keeps escaping them there.

Thanks @baluertl and @mortona2k for testing and moving this along.

  • dave reid committed 222a0e8d on 8.x-1.x authored by baluertl
    fix: #3402255 Stop double-escaping button labels in CKEditor 5
    
    By:...
dave reid’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • dave reid committed 222a0e8d on 2.0.x authored by baluertl
    fix: #3402255 Stop double-escaping button labels in CKEditor 5
    
    By:...