Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#14557 closed defect (bug) (duplicate)

Side by side shortcodes leave one as text

Reported by: adiant's profile adiant Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0.1
Component: Shortcodes Keywords: parsing
Focuses: Cc:

Description

Coding

[gallery][gallery]text

displays the current page's gallery then "[gallery]text". The problem reproduces consistently when coded using the HTML tab of TinyMCE in Edit Page, immediately hitting Update, and viewing the actual page.

This was first observed when using the Shortcode Exec PHP plug-in, so I installed a fresh version of WordPress and tested with the gallery shortcode to remove the possibility of this being a problem with the plug-in.

Change History (4)

#1 @adiant
14 years ago

  • Cc jon.pearkins@… added

#2 @scribu
14 years ago

Related: #14481

#3 @stringfold
14 years ago

  • Cc stringfold added

I can confirm this is a problem. If you have any two shortcodes directly one after the other (e.g. [tweet][like] then the regular expression in get_shortcode_regex() in shortcodes.php doesn't work.

For example, I have three shortcodes in a row: [facebook-lite][tweet-button][sharethis], but this is what the shortcode regex expression finds:

Array
(
[0] => >[facebook-like][
[1] => >
[2] => facebook-like
[3] =>
[4] =>
[5] =>
[6] => [
)
Array
(
[0] => ][sharethis]T
[1] => ]
[2] => sharethis
[3] =>
[4] =>
[5] =>
[6] => T
)

In other words, the middle shortcode of the three [tweet-button] is not found because it looks like the regex is picking up the opening bracket as part of the previous shortcode.

Sadly, I am not a regex expert so I have to decline to attempt to fix this. I suspect a competent regex person will be able to fix this in short order.

There is a workaround -- if you add any single character between the shortcodes then the regex works fine -- so you can use a space (or even  ) to prevent your adjoining shortcodes from disappearing.

This should be a one-line fix, so it would be nice to include it in a point release.

#4 @nacin
14 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.