Class attribute is removed from allowed html tags filter during migration from CKEditor 4 to 5

Created on 1 March 2024, 4 months ago
Updated 6 March 2024, 3 months ago

Problem/Motivation

During the auto-migrate process from CKEditor 4 to 5, if the Style plugin was not enabled previously in the CKEditor4, the class attribute for html tag that supported by a plugin, such as the A tag, will be removed from the allowed list in the 'Limit allowed HTML tags and correct faulty HTML' filter.
The consequence is that those contents were created in CKEditor 4, in which there is a link tag with class attribute will lose the styling as the 'class' attribute is filtered out after migrating to CKEditor 5.

Before migrated to CKEditor 5

After

The class attribute of the link is filtered out.

This bug only occur with the following conditions:

  • Migrate from CKEditor 4 to 5.
  • The Style plugin was not enabled prior to migration.
  • The class attribute is belong to a html tag that is supported by a CKEditor 5 plugin. For example <a> tag supported by the Link plugin.

Steps to reproduce

  1. Go to a text format config page (/admin/config/content/formats/manage/full_html)
  2. Chose the CKEditor 4 as the text editor.
  3. Remove the style plugin from the active toolbar.
  4. Tick the 'Limit allowed HTML tags and correct faulty HTML' filter and add the following into the 'Allowed HTML tags'
    <a class>
  5. Change the text editor to CKEditor 5
  6. At this point, there is a Drupal log said

    'The CKEditor 5 migration process enabled the following plugins to support specific attributes that are allowed by the Rich text text format: Style ( for tag: <a> to support: cla.'

    The typo in the log message is another problem.

  7. The a tag in the 'Allowed HTML tags' now is changed to <a href> and this setting is read-only in CKEditor 5.
  8. The style plugin is auto-enabled during the migrate process.But no allowed class attribute.

Proposed resolution

Leave the class attribute as it was in the 'Allowed HTML tags' setting after migrating to CKEditor 5 from 4.

Remaining tasks

A merge request to fix this bug.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

Fix a bug which cause an allowed tag's class attribute is filtered out unexpectedly after migrating from CKEditor 4 to 5.

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

ckeditor.module

Created by

πŸ‡¦πŸ‡ΊAustralia Mingsong πŸ‡¦πŸ‡Ί

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

Comments & Activities

Production build 0.69.0 2024