Make WordPress Core

Opened 8 years ago

Last modified 5 years ago

#34814 new defect (bug)

Presence of "Less than sign" < adds additional closing shortcode tag.

Reported by: alexanderrohmann's profile alexander.rohmann Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.2.3
Component: Shortcodes Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

If a < is used in shortcode content without a reciprocating > the shortcode closing tag will be duplicated. This was introduced in 4.2.3 as part of [33360].

For example, assuming [my_shortcode] simply returns it's content. This...
[my_shortcode]One < Two[/my_shortcode]

Should output this:
One < Two

But instead, we get this:

One < Two[/my_shortcode]

Consequently, a unit test somewhat like this won't pass:

    '[caption]Hello < World[/caption]', 
    'Hello < World'

I'm not 100% sure, but I suspect it's due to this regex:

By continuing to match all input, perhaps that also grabs the shortcode's closing tag, causing it to be duplicated.

Attachments (1)

- وورد تراك (312.7 KB) - added by rtyui091276 4 years ago.

Download all attachments as: .zip

Change History (3)

#1 @SergeyBiryukov
8 years ago

  • Description modified (diff)

#2 @alexander.rohmann
8 years ago

Pardon if I missed the ability to update the title, but I'm realizing it's less than accurate. The closing tag isn't being duplicated, it's just being output as plaintext, and the shortcode renders as if $content wasn't provided. This can probably just be closed. It's more an issue of using raw < symbols in content instead of HTML entities. Because the markup is already invalid it may not be worth updating the shortcode parser to accommodate.

Note: See TracTickets for help on using tickets.