Make WordPress Core

Opened 13 years ago

Closed 11 years ago

Last modified 6 years ago

#7943 closed defect (bug) (wontfix)

Image captions truncated if single quotes are added in the html editor

Reported by: designsimply Owned by:
Milestone: Priority: low
Severity: minor Version: 2.6
Component: Media Keywords: needs-patch
Focuses: Cc:


When adding captions with single or double quotes (if edited in HTML editor mode), saving or returning to visual editor mode truncates the caption.

To reproduce:

  • Open a new post
  • Insert an image with a caption
  • Switch to HTML editor
  • Modify caption to include a single quote or a double quote (i.e. it's the bestest caption ever! or hi "there")
  • Switch back to Visual editor and the caption will be truncated

I was able to reproduce this on Safari 3.1.2, Firefox 3.0.3, and Firefox on Mac OS X Leopard.

Change History (10)

#1 @Hirvine
13 years ago

The bug also makes it impossible to have elements having attributes alike a link inside the image caption. Which, I think, increments the piority.

Eg. '<a href=""></a>' breaks at the first quoute as designsimply says.

The caption is written using the 'new' shortcodes. The format caption="" format seems to support escaped quotes (\") but I'm not certain about that.
Using the HTML editor I escaped the quotes manually which makes the link or quoute correctly until the post is saved/published.

Hopeful this bit of information can help you out.

It is a code problem, so testing more web browsers is irrelevant.

#2 @azaozz
13 years ago

In the HTML editor single and double quotes have to be entered as HTML entities, this happent automatically in the Visual editor (so it works when entered there).

For now the caption doesn't support HTML tags, only text. Support for inline tags is planned but probably will be ready after 2.7.

#3 @ericr23
12 years ago

Just to second this bug: \" breaks the coding. Replacing \" with &quot; fixes it.

#4 @janeforshort
12 years ago

  • Milestone changed from 2.8 to Future Release

Punting due to feature freeze. Reconsider with next release.

#5 @Denis-de-Bernardy
12 years ago

  • Component changed from General to Media
  • Owner anonymous deleted
  • Priority changed from normal to low
  • Severity changed from normal to minor

confirming there are a few genuine bugs in there. but nothing that prevents things from working.

try an image with the caption:

it's a "caption"
  • insert in wysiwyg, go back and forth
  • insert in html instead, go back and forth

the text gets inconsistently processed/reprocessed. things do work. it might just confuse some users.

#6 @Denis-de-Bernardy
12 years ago

  • Keywords needs-patch added
  • Version set to 2.6

#7 @Denis-de-Bernardy
12 years ago

  • Milestone changed from Future Release to 2.9

#8 @toby lewis
12 years ago

The problem is not restricted to the html/visual editor because a caption short code with escaped double quotes in the caption parameter appears to break the shortcode parser.

The result of an image inserted with a caption that contains one or more double quotes (escaped or not) will be published without the caption div or caption paragraph surrounding the html image and link. Implying the shortcode failed to generate any output code.

Although it would be possible to use &quot;s in the caption text in the media library forms, it isn't reasonable to expect normal users to do this.

The solution is to alter the "insert into post" code to convert quotes to entities just prior to doing the addslashes.

#9 @azaozz
11 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

The visual editor takes care of this but in the HTML editor ' " have to be entered as entities in the caption.

#10 @DrewAPicture
6 years ago

  • Milestone 2.9 deleted
Note: See TracTickets for help on using tickets.