Discovered while porting the CKEditor Widget to Drupal core in #2994696: Render embedded media items in CKEditor.

The current upcasting logic only inspects the element's data- attributes, not the element name.
if (attributes['data-entity-type'] === undefined || (attributes['data-entity-id'] === undefined && attributes['data-entity-uuid'] === undefined) || (attributes['data-view-mode'] === undefined && attributes['data-entity-embed-display'] === undefined)) {

This means that <foo data-entity-type…> would also be upcasted. That does not match the filter's behavior, so let's restrict it.

Here's a video:
https://www.drupal.org/files/issues/2019-06-26/foo-upcasting.mov

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new1.37 KB
oknate’s picture

Issue summary: View changes
StatusFileSize
new2.27 MB
wim leers’s picture

#3: yep, that's the pre-patch behavior, right?

oknate’s picture

Status: Needs review » Reviewed & tested by the community

Yes, manually tested the patch, and it works. We could easily add test coverage.

wim leers’s picture

Test coverage would be lovely actually. That'd be the CKEditor plugin equivalent of \Drupal\Tests\entity_embed\Kernel\EntityEmbedFilterTest::testOnlyDrupalEntityTagProcessed() for the filter plugin.

oknate’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.49 KB
new2.49 KB
new3.78 KB

Adding test coverage.

The last submitted patch, 7: 3064288-7--TEST-ONLY.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

oknate’s picture

As a follow-up, we could test for each missing attribute.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

👍

wim leers’s picture

Category: Task » Bug report
wim leers’s picture

StatusFileSize
new4.03 KB
new4.46 KB

Test clean-up prior to commit.

BTW, #9: I think that's excessive :) This suffices.

The last submitted patch, 7: 3064288-7--TEST-ONLY.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

wim leers’s picture

Status: Reviewed & tested by the community » Fixed

DrupalCI is apparently down or massively overloaded, because even after >100 minutes it's still queuing 🤔

Don't have time to wait. Ran test locally. #12 introduced a CS violation. Fixed.

  • Wim Leers committed 04a59ec on 8.x-1.x authored by oknate
    Issue #3064288 by oknate, Wim Leers: Only upcast `<drupal-entity>`, not...
wim leers’s picture

StatusFileSize
new627 bytes

… and d.o apparently lost the interdiff I definitely uploaded in #14. Send hugs to drupal.org, it's apparently going through a rough time!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.