WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#20369 closed defect (bug) (fixed)

HTML captions: Using double quotes for attributes breaks the ouput

Reported by: ocean90 Owned by: azaozz
Milestone: 3.4 Priority: normal
Severity: normal Version: 3.4
Component: Shortcodes Keywords: has-patch
Focuses: Cc:

Description

Input:

<a href="http://google.de>Google</a> <span class="foo">Bar</span>

HTML editor output:

<a hrefArray>Google</a> <span classArray>Bar</span>

Visual editor output:

<a>Google</a> <span>Bar</span>

Confirmed by sabreuse too.

Related: #18311

Attachments (3)

20369.patch (1000 bytes) - added by SergeyBiryukov 8 years ago.
20369.minor-typo-fix.patch (531 bytes) - added by SergeyBiryukov 8 years ago.
20369.simplify.diff (521 bytes) - added by duck_ 8 years ago.

Download all attachments as: .zip

Change History (16)

#1 follow-up: @azaozz
8 years ago

Yes, when typing the caption shortcode by hand in the HTML editor (did you really do that?) care should be taken to use the right quotes.

Things like [shortcode arg="<tag attr="1">"] would of course break it same as any other string in PHP, JS, etc.

This is the only case where that could happen, in all other cases quotes are automatically converted to the proper format. Also when the shortcode is inserted from the media library popup (regardless of which editor is used), the quotes are in the right format (converted when needed).

#2 @azaozz
8 years ago

  • Component changed from Editor to Shortcodes
  • Keywords close added; needs-patch removed

#3 in reply to: ↑ 1 @ocean90
8 years ago

  • Keywords needs-patch added; close removed

Replying to azaozz:

Yes, when typing the caption shortcode by hand in the HTML editor (did you really do that?) care should be taken to use the right quotes.

No, I'm talking about the image properties popup.

http://f.cl.ly/items/3F0A430T0R3V0e1I2Z1a/Bildschirmfoto%202012-04-06%20um%2014.47.53.png

sabreuse@IRC:

oh. buggy. When I added a caption at the time I first uploaded the image, it stripped the href attribute - so I got bare <a> tags, but not >the hrefArray you're seeing. When I inserted a caption on an image that was already in the post (i.e. with the edit button that appears on >rollover in the editor), the link worked fine.

#4 @SergeyBiryukov
8 years ago

  • Keywords has-patch added; needs-patch removed

There's also a notice:

Notice: Array to string conversion in includes/media.php on line 173

20369.patch seems to fix the issue.

#5 @azaozz
8 years ago

I see, since the second callback fails, it never gets to the bits that replace double with single quotes.

#6 follow-up: @azaozz
8 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In [20376]:

Fix second callback when filtering caption text for shortcode, props SergeyBiryukov, fixes #20369

#7 @SergeyBiryukov
8 years ago

There's also a tab where a space should be instead (20369.minor-typo-fix.patch).

#8 @azaozz
8 years ago

In [20377]:

Pluck a tab (whitespace), props SergeyBiryukov, see #20369

#9 @ocean90
8 years ago

Works now. :)

@duck_
8 years ago

#10 in reply to: ↑ 6 ; follow-up: @duck_
8 years ago

Replying to azaozz:

In [20376]:

Fix second callback when filtering caption text for shortcode, props SergeyBiryukov, fixes #20369

That code can be simplified to remove the isset() check. The function will not be called unless there was a match which means that key 0 will be set.

See 20369.simplify.diff. I also changed the parameter to $matches since it's not actually a string.

#11 in reply to: ↑ 10 @azaozz
8 years ago

Replying to duck_:

Right. The same is true for _cleanup_image_add_caption() callback right above this one. Could you put these in plz.

#12 @duck_
8 years ago

In [20381]:

Simplify caption cleanup callbacks; if the function was called we know that the 0 index is set. See #20369.

#13 @nacin
8 years ago

In [20382]:

Use _callback, rather than an unhelpful 2, for a preg_replace callback function name. Add proper phpdoc. see #20369.

Note: See TracTickets for help on using tickets.