Problem/Motivation

HTML characters aren't escaped/encoded in the media embed caption field. Anything with the > character causes everything before > to get truncated, breaking the embed.

Which is to say, this:
caption with rich html

produces this:
broken embed

Proposed resolution

I THINK from rooting around that the entity embed popover caption field is supposed to encode any HTML characters for decoding on render.

(...and if someone can figure this out, allowing HTML in the caption, would it be possible to wrap that caption field in the popover with a ckeditor instance of its own, so that editors can have inline buttons for link/strong/em/ul/etc so they don't have to write raw html?)

Remaining tasks

User interface changes

Possibly a ckeditor instance in the popup?

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

itmaybejj created an issue. See original summary.

itmaybejj’s picture

Issue summary: View changes
itmaybejj’s picture

My apologies for talking to myself...

As I poke around at this, I'm realizing the data-caption approach might work fine if the html characters could be properly encoded...so this might just be an encoding/escaping problem.

Strong/em/a are very common in captions...I could imagine list items too...but in practice -- if we could encode html, couldn't we slap a ckeditor profile on this and give it a set of buttons in the modal? Then users could turn rich text on and off, and pick their own buttons...

itmaybejj’s picture

Category: Feature request » Bug report
Issue summary: View changes

rewriting summary as a bug report; feature request was based on my thinking the approach was the problem; on further rooting around I think the approach is fine but there is a bug on the modal dialog...

itmaybejj’s picture

Issue summary: View changes
balsama’s picture

Project: Lightning » Entity Embed
Component: Configuration » Code

Thanks John. Migrating this to Entity Embed after speaking with Dave Reid.

Dave Reid’s picture

@itmaybejj: What input format were you using while embedding the content?

I definitely agree that editing the caption inline in the editor would be preferred.

balsama’s picture

@Dave Reid - I can't speak for @itmaybejj, but since this was originally filed against Lightning, he was probably using the text format that comes with that. The config for that format can be found here:

https://github.com/acquia/lightning/blob/8.x-1.x/modules/lightning_featu...

Dave Reid’s picture

@balsama: Thanks, I'm definitely able to replicate with that configured text format + CKEditor (thanks D8 for making it easy to import arbitrary config!)

Dave Reid’s picture

Based on #2105841: Xss filter() mangles image captions and title/alt/data attributes it looks like we need to ensure that captions are double-escaped, not just escaped as an attribute.

Dave Reid’s picture

Status: Active » Needs review
FileSize
1.92 KB

Here's the patch version of the pull request at https://github.com/drupal-media/entity_embed/pull/212 that should resolve it, for anyone that needs this in a distro or project.

Dave Reid’s picture

Note that any existing captions likely would need to be re-edited to be encoded properly in the filtered text fields.

Dave Reid’s picture

  • Dave Reid committed 990602c on 8.x-1.x
    Issue #2688427 by Dave Reid: Ensure the caption value is double-encoded...
Dave Reid’s picture

Status: Needs review » Fixed

Committed the fix to 8.x-1.x!

itmaybejj’s picture

This is my happy dance. Thank you all!

Status: Fixed » Closed (fixed)

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

Wim Leers’s picture