Ticket #13064 (confirmed Bug)
image-caption with ampersand (&) incorrectly encoded
Reported by: | teschmitz | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 4.x |
Component: | Visual Editor | Version: | 4.1 |
Keywords: | image-caption | Cc: | teschmitz |
Description
An image caption containing an ampersand is incorrectly encoded.
For example, "M & S" results in "M & S", which displays as "M & S". Other url-encoded entities such as the copyright symbol are correctly encoded.
Change History
comment:1 Changed 4 years ago by kleist
- Status changed from new to confirmed
- Component changed from Unknown to Visual Editor
comment:3 Changed 4 years ago by teschmitz
I am probably trying to be too clever for myself here:
I think this will be something along the lines of being url-encoded twice. I have a feeling it is in plone.outputfilters resolveuid_and_caption.py: first the Description gets a going-over by aq_acquire () (which I think url-encodes the Title also); then handle_captioned_image () runs html_quote() over it.
comment:4 Changed 4 years ago by kleist
Could you please provide a recipe for how to reproduce this?
My assumption that this is about TinyMCE is probably wrong, since I can't reproduce with Plone 4.3 coredev buildout.
comment:5 Changed 4 years ago by teschmitz
example: http://my.mutterings.co.uk/politics/events/yesscotland-at-garthamlock-craigend-east-parish-church
The map image has an "&" in the title and the description. Hover over the image and you'll see that alt and title tag have been correctly url-encoded. The description has been encoded twice as I described in my previous post:
& > & > &
I tried my suggestion of last night and made the following change (on a test site) in plone/outputfilters/filters/resolveuid_and_caption.py
#'caption': newline_to_br(html_quote(caption)), 'caption': newline_to_br(caption),
It works and I am not aware of it breaking anything else.
comment:6 Changed 4 years ago by teschmitz
how to reproduce
- create an Image with an "&" in the description
- insert this image on a Page as captioned image
- using TinyMCE:
- change Site Setup > TinyMCE > Resource Types tab: tick "Allow Captioned Images"
- edit a page and insert the picture with "Caption" ticked (gives it class "captioned")
- using CKEditor:
- make sure the image has class "captioned"
Images with that class get the following treatment by Plone.outputfilters: The Image description will become the caption. It is all contained in resolveuid_and_caption.py:
function resolve_image() calls aq_acquire(Description), which I url-encodes the Description. The result is put in a field called "caption", which is passed to handle_image_caption(). There the caption is passed through html_quote(), which url-encodes the same string again.
That's ok for copyright symbols etc but an ampersand will get done again.
comment:8 Changed 4 years ago by teschmitz
Plone 4.1.4 and plone.outputfilters 1.2
You can also view it on this public site:
Ploud, created ten minutes ago http://ampersand.ploud.com/marks-spencer The set up on this site:
- Plone 4.1.5 (4114)
- CMF 2.2.6
- Zope 2.13.13
- Python 2.7.3 (default, May 9 2012, 20:18:57) [GCC 4.4.3]
- PIL 1.1.6