[wp-trac] [WordPress Trac] #33134: Complex Nested Shortcodes Inside of Attributes Are Not Processed Left-to-Right

WordPress Trac noreply at wordpress.org
Mon Jul 27 02:34:48 UTC 2015


#33134: Complex Nested Shortcodes Inside of Attributes Are Not Processed Left-to-
Right
--------------------------+------------------------------
 Reporter:  miqrogroove   |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Shortcodes    |     Version:  4.2.3
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------
Description changed by miqrogroove:

Old description:

> Given the following input pattern, the 4.2.3 update alters the flow of
> control very slightly, which could give the appearance that shortcodes
> are "not working".
>
> {{{[myloop]<html attr="[dependent]">[/myloop]}}}
>
> The preferred input pattern is the one in which the shortcodes output
> their own HTML, and this is unchnaged by the update to 4.2.3:
>
> {{{[myloop][dependent][/myloop]}}}
>
> Additional considerations:
>
> The Shortcode API does not process nested shortcodes.  This only happens
> when plugins run do_shortcode() recursively.
>
> Core devs have not yet considered whether this is a bug, nor to which
> Milestone it might be assigned.
>
> Algorithm required for do_shortcode to partially restore left-to-right
> processing:
>
> 1. Parse HTML.
> 1. Replace all shortcodes found in attributes with unique, non-shortcode,
> non-HTML placeholders.
> 1. Implode HTML.
> 1. Run shortcode regexp.
> 1. Before calling each custom handler, the placeholders would have to be
> undone inside of each wrapping shortcode.
> 1. Call custom handler.  At this point, the custom handler is able to get
> left-to-right recursion.
> 1. Escape all shortcodes and placeholders in shortcode output (callback
> abstraction needed?)
> 1. Undo all remaining placeholders.
> 1. Parse HTML (again, from the top)
> 1. Do shortcodes in attributes. (Not inside wrapping shortcodes).
> 1. KSES filters the shortcode output.
> 1. Implode HTML.

New description:

 Given the following input pattern, the 4.2.3 update alters the flow of
 control very slightly, which could give the appearance that shortcodes are
 "not working".

 {{{[myloop]<html attr="[dependent]">[/myloop]}}}

 The preferred input pattern is the one in which the shortcodes output
 their own HTML, and this is unchanged by the update to 4.2.3:

 {{{[myloop][dependent][/myloop]}}}

 Additional considerations:

 The Shortcode API does not process nested shortcodes.  This only happens
 when plugins run do_shortcode() recursively.

 Core devs have not yet considered whether this is a bug, nor to which
 Milestone it might be assigned.

 Algorithm required for do_shortcode to partially restore left-to-right
 processing:

 1. Parse HTML.
 1. Replace all shortcodes found in attributes with unique, non-shortcode,
 non-HTML placeholders.
 1. Implode HTML.
 1. Run shortcode regexp.
 1. Before calling each custom handler, the placeholders would have to be
 undone inside of each wrapping shortcode.
 1. Call custom handler.  At this point, the custom handler is able to get
 left-to-right recursion.
 1. Escape all shortcodes and placeholders in shortcode output (callback
 abstraction needed?)
 1. Undo all remaining placeholders.
 1. Parse HTML (again, from the top)
 1. Do shortcodes in attributes. (Not inside wrapping shortcodes).
 1. KSES filters the shortcode output.
 1. Implode HTML.

--

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33134#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list