From 7a35bff9163032f7071e0b52fd756ab3ca5e53e9 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Fri, 7 Aug 2015 02:49:31 +0000 Subject: [PATCH] Fix `do_shortcode('<[shortcode]')` edge case. Props miqrogroove. Merges [33499] trunk. See #33116. git-svn-id: https://develop.svn.wordpress.org/trunk@33594 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/shortcodes.php | 5 +++++ tests/phpunit/tests/shortcode.php | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/wp-includes/shortcodes.php b/src/wp-includes/shortcodes.php index 4c9355f6b6..d16227ea3c 100644 --- a/src/wp-includes/shortcodes.php +++ b/src/wp-includes/shortcodes.php @@ -359,6 +359,11 @@ function do_shortcodes_in_html_tags( $content, $ignore_html ) { $attributes = wp_kses_attr_parse( $element ); if ( false === $attributes ) { + // Some plugins are doing things like [name] <[email]>. + if ( 1 === preg_match( '%^<\s*\[\[?[^\[\]]+\]%', $element ) ) { + $element = preg_replace_callback( "/$pattern/s", 'do_shortcode_tag', $element ); + } + // Looks like we found some crazy unfiltered HTML. Skipping it for sanity. $element = strtr( $element, $trans ); continue; diff --git a/tests/phpunit/tests/shortcode.php b/tests/phpunit/tests/shortcode.php index 0f251d4933..44abc2754f 100644 --- a/tests/phpunit/tests/shortcode.php +++ b/tests/phpunit/tests/shortcode.php @@ -434,6 +434,14 @@ EOF; '
', '
', ), + array( + '<[[gallery]]>', + '<[gallery]>', + ), + array( + '
', + '
', + ), array( '[gallery]
Hello
[/gallery]', '', @@ -472,6 +480,10 @@ EOF; '
', // Shortcodes will never be stripped inside elements. '
', ), + array( + '<[[gallery]]>', + '<[[gallery]]>', + ), array( '[gallery]
Hello
[/gallery]', '',