WordPress.org

Make WordPress Core

Opened 10 months ago

Last modified 10 months ago

#45493 new defect (bug)

Square brackets in caption shortcode produce improper formatting

Reported by: Christian1012 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9.8
Component: Editor Keywords: has-patch
Focuses: Cc:

Description

If [square] brackets are placed inside of a

[caption]

shortcode, the resulting formatting is broken when the captioned image is surrounded by text content.

If you paste the following into the text editor, switch to visual, and then back to text, you'll notice the line break after the caption disappears.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

[caption id="attachment_143591" align="aligncenter" width="700"]<img class="size-full wp-image-143591" src="https://placehold.it/700x800" alt="" width="700" height="800" /> This is a caption with some [square] braces that make it appear like another shortcode.[/caption]

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.

I'm not sure why this is happening, it may be related to some code thinking that the square brace inside the caption indicates it may be another shortcode. Escaping the shortcode using double brackets didn't have any affect.

Attachments (1)

45493.diff (787 bytes) - added by Christian1012 10 months ago.

Download all attachments as: .zip

Change History (2)

#1 @Christian1012
10 months ago

  • Keywords has-patch added; needs-patch removed
Note: See TracTickets for help on using tickets.