Opened 6 years ago
Last modified 17 months ago
#45493 reopened defect (bug)
Square brackets in caption shortcode produce improper formatting
Reported by: | Christian1012 | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 4.9.8 |
Component: | Editor | Keywords: | has-patch needs-testing |
Focuses: | javascript | 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 (4)
Change History (14)
This ticket was mentioned in Slack in #core by noisysocks. View the logs.
5 years ago
#3
@
5 years ago
- Keywords reporter-feedback needs-testing added
- Milestone changed from Awaiting Review to Future Release
#4
@
5 years ago
- Keywords reporter-feedback removed
- Resolution set to invalid
- Status changed from new to closed
Sorry this was a while ago. The patch I attached adds support for escaping brackets inside shortcodes, using the escaping method introduced in #6518.
[shortcode] Double brackets are [[escaped]] with entities. [/shortcode]
I tested the original patch, still seems to work for me, as long as you double escape. Adding an updated patch with proper formatting.
#6
@
5 years ago
On thinking more about this, it might just make sense to escape brackets inside the captions.
#8
@
21 months ago
Test Report
This report validates that the indicated patch addresses the issue.
Patch tested: https://core.trac.wordpress.org/ticket/45493
Environment
- OS: macOS 13.1
- Web Server: Nginx
- PHP: 8.0
- WordPress: 6.3
- Browser: Chrome 111.0.5563.146
- Theme: Twenty Twenty-Three
- Active Plugins:
Actual Results
- The issue was not resolved with a patch. Also, the issue is not reproduced stably.
- I tested it on Post and Page
Additional Notes
- Steps to reproduce:
- Paste the given text into the code editor
- Switch to the visual editor
- Back to the code editor.
Also, I checked on Draft and Publish and on the frontend.
Hi @Christian1012 ! Thanks so much for the ticket and the patch, and apologies for the long wait on a reply.
We talked about this in today's triage.
Multiple folks were able to confirm the issue, but I still saw the problem after applying the patch.
Would you mind taking a look to see if it's still fixing the problem for you?
Either way, I'm going to mark it Future Release, since the bug is reproducible.
Thanks again!