Closed (fixed)
Project:
Panopoly
Version:
7.x-1.x-dev
Component:
WYSIWYG
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Jun 2014 at 17:24 UTC
Updated:
7 Aug 2014 at 12:00 UTC
Jump to comment: Most recent
If you insert an image which has a character in its alt or title text that is encoded as an entity, such as an apostrophe, every time you save the page, the ampersand part of the entity code gets encoded again.
Sample after 4 saves:
<p>This page tests encoding of HTML entities in image alt and title text.</p>
<p>For comparison, here are some textual things that should be encoded as entities...</p>
<ol>
<li>Apostrophes/Single quotes: 'Quoted text'</li>
<li>Double quotes: "Quoted text"</li>
<li>Angle brackets: 3.2 < 54 and x > y.</li>
<li>Ampersands: Salt & pepper. Rice & beans.</li>
</ol>
<p>Image with alt and title text that contains apostrophes:</p>
<p><img alt="Green grass and blue sky&amp;amp;amp;amp;#039;s the limit" title="Cool pic of grass from the ant&amp;amp;amp;amp;#039;s eye view" class="panopoly-image-quarter media-element file-teaser panopoly-image-quarter" src="/sites/default/files/styles/panopoly_image_quarter/public/7787881458_ebda60dbaa_b.jpg?itok=23Xan-2g" /></p>
<p>Saved once.<br />Saved twice.<br />Saved three times.<br />Saved 4 times.</p>
Comments
Comment #1
dsnopekRetesting this with the latest Panopoly Git, it still appears to be double encoding the alt and title text, however only once. Saving the node multiple times isn't causing it to encoding the entities multiple times.
However, this no longer appears to affect apostrophe's (they are no longer HTML encoded for some reason), but still does affect ampersands and greater than or less than symbols.
Comment #2
dsnopekI created a patch for Media which should fix this: #2308487: Alt and Title double encoded in WYSIWYG
It could use more testing, though!
Note: this is much easier to test when you're also using the other alt/title related changes that were just committed to Panopoly with #2307007: When inserting Image in WYSIWYG, the second set of alt/title fields is ignored
Comment #3
dsnopekGot some manual testing from @cboyden on #2308487: Alt and Title double encoded in WYSIWYG!
I've committed this patch upstream. Let's see what Travis-CI says:
https://travis-ci.org/panopoly/panopoly/builds/30742296
I'd still like to get some tests done in #2308325: Write Behat test for alt/title text on images in the WYSIWYG but it's been slow going...