Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#28797 closed defect (bug) (invalid)

Shortcodes Run on Partial Match

Reported by: brianjohnsondesign's profile brianjohnsondesign Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5.2
Component: Shortcodes Keywords:
Focuses: Cc:

Description

Note: This was on a slightly older version of WordPress, maybe it was fixed since then, but I haven't seen anything about it.

I have a very simple custom plugin, which defines two shortcodes, [close_out_display] and [close_out].

I was having some issues with it, and eventually realized that the shortcode [close_out_display] would run the function tied to [close_out], or at least parts of it. It would appear that nothing was being echoed, but the function included some changes to user meta that were occurring. To isolate the problem, I even removed, entirely, the function to create the [close_out_display] function, leaving only [close_out] defined.

On a page with no other content, I added "[close_out_display]". Sure enough, the [close_out] function still ran.

Then I tried changing the SHORTCODE definition for [close_out] to [close_out1]. It did NOT run.

Then I changed the CONTENT of the page to be [close_14124] and it did NOT run.

I tried various tests, and eventually came to the conclusion that as long as the name of the function's shortcode is matched, in its entirety, as the first characters of the shortcode in the content, it would run. For instance, if it is defined as [close_out], then anything from [close_out124521512] to [close_out_acasdcasfweiocen] would still run it.

I understand that shortcodes utilize variables and what not, but isn't the first section of the shortcode, before any spaces, ALWAYS supposed to match, exactly, the name of the shortcode? Shouldn't extra characters cause it not to function?

Change History (5)

#1 @brianjohnsondesign
11 years ago

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

#2 @brianjohnsondesign
11 years ago

I've got a lot of weird stuff going on here, that I need to figure out. It seemed really cut-and-dry before, but it's not really. So I don't know what the deal is.

#3 @SergeyBiryukov
11 years ago

  • Milestone Awaiting Review deleted

#4 follow-up: @brianjohnsondesign
11 years ago

Found out later that the issue was being caused by Browser Prefetching, particularly in Firefox. Shortcodes in the content of the "next" page were being run, even before you ever went to that page. I would recommend just removing the "next" and "previous" links to avoid this issue.

#5 in reply to: ↑ 4 @SergeyBiryukov
11 years ago

Replying to brianjohnsondesign:

I would recommend just removing the "next" and "previous" links to avoid this issue.

See #21658.

Note: See TracTickets for help on using tickets.