Opened 9 years ago
Last modified 3 years ago
#26649 reopened defect (bug)
escaped shortcodes should not be expanded during 'get_the_excerpt'
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.7.1 |
Component: | Shortcodes | Keywords: | needs-patch needs-unit-tests |
Focuses: | Cc: |
Description
It is possible for "the_content" filter to be invoked while processing "get_the_excerpt".
If the do_shortcodes() filter hook is attached to both "the_content" and "get_the_excerpt" then this can lead to an unexpected expansion of an escaped shortcode.
This can lead to unwanted side effects, as reported here.
http://www.oik-plugins.com/2013/12/escaped-shortcodes-unexpectedly-expanded-get_the_excerpt/
This minor problem can be alleviated by a simple change to strip_shortcode_tag(), returning the HTML code [ as the first character rather than the left square bracket.
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]; }
I don't believe that it's necessary to make the same change in do_shortcode_tag().
Attachments (1)
Change History (7)
#1
@
9 years ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
Duplicate of #19927.
#2
follow-up:
↓ 3
@
9 years ago
- Resolution duplicate deleted
- Status changed from closed to reopened
Hi Sergey. Thanks for finding 19927 for me. I wondered why my patch had two changes.
The change in 19927 is for do_shortcode_tag()
The second part of the change, in 26649, is for strip_shortcode_tag().
The problem is not exactly a duplicate as the fix for 26649 handles the situation where shortcodes are being removed.
The patch for 26649 will work for 19927 but not vice-versa.
How should this be addressed?
patch for 26649