Problem/Motivation

When you add an image through the wysiwyg and try to add a plain-text tag, it gets removed after save/reopen or switching to source and back to WYWISYG:

Adding the caption:

Switching to source:

Switching back to WYSIWYG:

Proposed resolution

Remaining tasks

Provide a patch.

User interface changes

None.

API changes

None (?)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Title: Image captions incorrectly deal with plain-text tags » Image captions incorrectly deal with plain-text HTML tags
Component: editor.module » ckeditor.module
Assigned: Unassigned » Wim Leers
Issue tags: +CKEditor in core, +Spark

Already talking with the CKEditor developers about this.

This is what I told them:

1. So when looking at the widget, I paste this into the caption box:
"<a href="http://drupal.org">test</a>"

2. Then I switch to source mode. There, I see this:

<img alt="test" data-align="center" data-caption="&lt;a href=&quot;http://drupal.org&quot;&gt;test&lt;/a&gt;" data-entity-type="file" data-entity-uuid="64d913a0-1c62-4e33-a809-09b201392fba" height="232" src="/sites/default/files/inline-images/hipster%20llama.jpg" width="417" />

As you can see, not double-encoded, whereas it should be.

Wim Leers’s picture

Wim Leers’s picture

Assigned: Wim Leers » Unassigned
Status: Active » Postponed
Issue tags: +Needs upstream bugfix

Confirmed that this is a CKEditor bug. Ticket filed: http://dev.ckeditor.com/ticket/13105. Demonstration of the bug:

Copy/pasted from the Chrome developer console, to demonstrate a bug.

var e = CKEDITOR.tools.htmlEncode
undefined

var d = CKEDITOR.tools.htmlDecode
undefined

e('<tag>')
"&lt;tag&gt;"

e(e('<tag>'))
"&amp;lt;tag&amp;gt;"

d(e('<tag>'))
"<tag>"

d(e(e('<tag>')))
"<tag>"

d(e(e(e(e('<tag>')))))
"&amp;amp;lt;tag&amp;amp;gt;"

d(e(e(e('<tag>'))))
"&amp;lt;tag&amp;gt;"

d(e(e('<tag>')))
"<tag>"
mgifford’s picture

Status: Postponed » Active

Fixed in CKEditor 4.5.0 so think we can resolve this now.

Wim Leers’s picture

Status: Active » Fixed
Issue tags: -Needs upstream bugfix
Related issues: +#2521820: Update CKEditor library to 4.5.3

Hurray, this is indeed completely fixed since upgrading to CKE 4.5.3 in #2521820: Update CKEditor library to 4.5.3!

Re-running the scenario in #3 now produces vastly different results:

var e = CKEDITOR.tools.htmlEncode
undefined

var d = CKEDITOR.tools.htmlDecode
undefined

e('<tag>')
"&lt;tag&gt;"

e(e('<tag>'))
"&amp;lt;tag&amp;gt;"

d(e('<tag>'))
"<tag>"

d(e(e('<tag>')))
"&lt;tag&gt;"

d(e(e(e(e('<tag>')))))
"&amp;amp;lt;tag&amp;amp;gt;"

d(e(e(e('<tag>'))))
"&amp;lt;tag&amp;gt;"

d(e(e('<tag>')))
"&lt;tag&gt;"
mgifford’s picture

Thanks for your work with the CKEditor community Wim!

Status: Fixed » Closed (fixed)

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