[wp-trac] [WordPress Trac] #26649: escaped shortcodes should not be expanded during 'get_the_excerpt'
WordPress Trac
noreply at wordpress.org
Tue Feb 10 10:12:56 UTC 2026
#26649: escaped shortcodes should not be expanded during 'get_the_excerpt'
-------------------------------------------------+-------------------------
Reporter: bobbingwide | Owner: (none)
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 7.0
Component: Shortcodes | Version: 3.7.1
Severity: normal | Resolution: invalid
Keywords: has-patch good-first-bug has-unit- | Focuses:
tests early |
-------------------------------------------------+-------------------------
Changes (by rkdevops24):
* status: reopened => closed
* resolution: => invalid
Comment:
Replying to [ticket:26649 bobbingwide]:
> The issue arises because do_shortcodes() is hooked to both the_content
and get_the_excerpt, and during excerpt generation WordPress may apply
filters in a way that causes escaped shortcodes ([[shortcode]]) to be
unexpectedly expanded.
>
> 1. get_the_excerpt() may indirectly trigger the_content filters.
> 2. If do_shortcodes() is attached to both hooks, escaped shortcodes can
be processed twice.
> 3. strip_shortcode_tag() currently returns [ when handling escaped
shortcodes.
> 4. That literal [ allows the shortcode to be re-interpreted and expanded
later in the filter chain.
>
> {{{
> function strip_shortcode_tag( $m ) {
> // allow [[foo]] syntax for escaping a tag
> if ( $m[1] == '[' && $m[6] == ']' ) {
> return "[" . substr($m[0], 2, -1);
> }
> return $m[1] . $m[6];
>}
> }}}
>
> You are correct — modifying do_shortcode_tag() is unnecessary because:
1. The issue is not with execution of valid shortcodes.
2. The problem specifically concerns escaped shortcode restoration.
3. The fix belongs at the unescaping stage (strip_shortcode_tag()).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/26649#comment:35>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list