[wp-trac] [WordPress Trac] #57790: Parsing of Shortcode Attributes: bug locating a final attribute

WordPress Trac noreply at wordpress.org
Wed Feb 22 19:00:17 UTC 2023


#57790: Parsing of Shortcode Attributes: bug locating a final attribute
--------------------------+-------------------------------------------
 Reporter:  lemernbag     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  assigned
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Shortcodes    |    Version:  6.1.1
 Severity:  normal        |   Keywords:  needs-patch changes-requested
  Focuses:                |
--------------------------+-------------------------------------------
 `shortcode_parse_atts()` uses the `get_shortcode_atts_regex()` pattern to
 return all `attribute="value"` matches, however the pattern does not
 account for shortcode strings where the final attribute pair does not have
 a space between `"` and `]`
 \\
 \\
 {{{
 shortcode_parse_atts('[shortcode-name category="banana-stand"
 money="yes"]'); //no space
 }}}
 returns
 {{{
 Array(
     [0] => [shortcode-name
     [category] => banana-stand
     [1] => money="yes"]
 )
 }}}
 \\
 whereas
 \\
 {{{
 shortcode_parse_atts('[shortcode-name category="banana-stand" money="yes"
 ]'); //has space
 }}}
 returns
 {{{
 Array(
     [0] => [shortcode-name
     [category] => banana-stand
     [money] => yes
     [1] => ]
 )
 }}}

 I ran the `get_shortcode_atts_regex()` pattern through a couple regex
 testers and verified that the issue is the non-capturing group conditional
 following the end-quote of a value.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57790>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list