Make WordPress Core

Opened 17 months ago

Last modified 17 months ago

#57790 reopened defect (bug)

Parsing of Shortcode Attributes: bug locating a final attribute

Reported by: lemernbag's profile lemernbag Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.1.1
Component: Shortcodes Keywords: needs-patch changes-requested 2nd-opinion
Focuses: Cc:

Description

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.

Change History (2)

#1 @alimuzzamanalim
17 months ago

  • Keywords 2nd-opinion added
  • Resolution set to invalid
  • Status changed from assigned to closed

Check the do_shortcode function.

It uses the get_shortcode_regex function to separate the shortcode name and attributes.
Then only passes the attributes to the shortcode_parse_atts function.

So I don't see any reason to treat it as a bug.

#2 @alimuzzamanalim
17 months ago

  • Resolution invalid deleted
  • Status changed from closed to reopened
Note: See TracTickets for help on using tickets.