Review main Merged

82012[BUGFIX] Avoid <o:p> tags pasted from MS Word into CKEditor5

Benjamin Franzke CR +2 V +2 Normal +59 −5 updated 12/12/23, 09:27

Commit message

With #99738 the option to allow all classes has been reenabled,
which implicitly caused all custom html elements to be allowed:

```
    htmlSupport:
      allow:
        - { classes: true, attributes: { pattern: 'data-.+' } }
```

The rule matched to any HTML element available in the CKEditor5 General
HTML Support (GHS) schema definition, including the pseudo element
`'$customElement'` that acts as placeholder for custom elements,
because the omitted `name` matcher implicitly acted like a match-all
(`.*`) pattern.

This became an issue, since `@ckeditor/ckeditor5-paste-from-office`
relies on the fact, that the pasted HTML is sanitized by GHS.
Namespaced tags like `<o:p>` (which the desktop version of microsoft
office likes to include when using copy&paste) where now allowed.

To account for this behavior we change two things:

1) We drop the default allow-list configuration that was added in
   v12.4.7, since the negative side effects outweighed the benefits:
   * All HTML Tags where implicitly allowed, which allowed any tags,
     even custom elements to be inserted via copy&paste or via source
     editor
   * All classes were enabled, thus custom Microsoft office classes
     started to pollute the HTML sources.
   * The configuration could not be removed/changed by an integrator
     since htmlSuppot.allow is an array and was therefore only appended,
     but never overwritten by custom RTE configurations

  We considered to switch to a name pattern like `[a-z]+` in our default
  configuration but decided against that because that'd still allow all
  other official HTML elements which is not good default, given that it
  can't be changed as described above.

2) We now restrict migrated CKEditor v4 (extra)allowedContent
   (e.g. `extraAllowedContent: *[*](*){*}`) match-all-elements
   directives (first asterisk in the example) to plain selectors in
   order to exclude custom or namespaced elements like `<o:p>`.
   We therefore migrate to a matcher pattern `[a-z]+` in order for the
   virtual custom-element entry `'$customElement'` to become a no-match.

Integrators are actually expected to define the set of allowed classes
with the CKEditor5 `style.definitions[]` configuration array.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Georg Ringer +1
    • Benni Mack +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Georg Ringer +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 3

Files 4

Review log 1621

  1. Benjamin Franzke commented on patch set 1 11/28/23, 14:31

    Cherry Picked from branch 12.4.
  2. Benjamin Franzke marked it ready for review 11/28/23, 14:31

  3. core-ci voted on patch set 1 V +1 11/28/23, 14:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50057

  4. Garvin Hicking commented on patch set 1 11/28/23, 22:50

    This still also scrubs tags like "script" at some later point, even if they match [a-z] right?
  5. Benjamin Franzke commented on patch set 1 CR -2 11/29/23, 06:47

    Reply

    Yes, it is escaped due to our html-sanitizer, but it is annoying to have it kinda allowed in the first place (although not being executed). I'm really leaning towards dropping this `classes: true` compat thingy (in v12 with an Important.rst), its problems are really annoying. Side note: that's all just because I wanted to assure that a v10/v11 updated to v12 doesn't loose HTML data when an editor opens an existing record and simply saves it – that's why I've added `classes: true` at all – other than that all allowed classes should be defined as style sets, which makes them implicitly allowed, so `classes: true` would not be needed for "properly" configured installations. Also with `classes: true` we'll always see the annoying ms-office classes in HTML, since all of them count as allowed while they are pasted. Thanks for the heads up. So I'm -2 this for now, I need to think about this…
  6. Benjamin Franzke uploaded patch set 2 V +1 12/11/23, 17:26

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  7. Benjamin Franzke voted on patch set 2 CR 0 12/11/23, 17:26

  8. core-ci voted on patch set 2 V +1 12/11/23, 17:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50568

  9. Benjamin Franzke commented on patch set 2 12/11/23, 17:40

    Reply

    Decided to drop this rule as the downsides outweighed the benefits.
  10. Benjamin Franzke uploaded patch set 3 V +1 12/11/23, 17:59

  11. Benjamin Franzke uploaded patch set 4 12/11/23, 18:01

  12. core-ci voted on patch set 3 V +1 12/11/23, 18:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50569

  13. core-ci voted on patch set 4 V +1 12/11/23, 18:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50570

  14. Georg Ringer voted on patch set 3 CR +1 V +1 12/11/23, 19:54

  15. Benjamin Franzke updated the commit message in patch set 5 V +1 12/12/23, 06:16

  16. core-ci voted on patch set 5 V +1 12/12/23, 06:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50575

  17. Benni Mack voted on patch set 5 CR +1 V +1 12/12/23, 08:35

  18. Benjamin Franzke commented on patch set 5 12/12/23, 09:11

    FYI: Tested against/with the update to CKEditor5 v40.2, this patch is still needed: > 82172: [TASK] Update ckeditor5 to v40.2 | https://review.typo3.org/c/Packages/TYPO3.CMS/+/82172
  19. Georg Ringer voted on patch set 5 CR +1 V +1 12/12/23, 09:23

  20. Benjamin Franzke voted on patch set 5 CR +2 V +2 12/12/23, 09:27

  21. Benjamin Franzke merged patch set 6 12/12/23, 09:27