diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 659db978d8..e9adb438f5 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -216,7 +216,7 @@ function wptexturize( $text, $reset = false ) { // Look for shortcodes and HTML elements. - preg_match_all( '@\[/?([^<>&/\[\]\x00-\x20]++)@', $text, $matches ); + preg_match_all( '@\[/?([^<>&/\[\]\x00-\x20=]++)@', $text, $matches ); $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); $found_shortcodes = ! empty( $tagnames ); $shortcode_regex = $found_shortcodes ? _get_wptexturize_shortcode_regex( $tagnames ) : ''; diff --git a/src/wp-includes/shortcodes.php b/src/wp-includes/shortcodes.php index 3967270922..132d63a5dc 100644 --- a/src/wp-includes/shortcodes.php +++ b/src/wp-includes/shortcodes.php @@ -95,9 +95,9 @@ function add_shortcode($tag, $func) { return; } - if ( 0 !== preg_match( '@[<>&/\[\]\x00-\x20]@', $tag ) ) { - /* translators: %s: shortcode name */ - $message = sprintf( __( 'Invalid shortcode name: %s. Do not use spaces or reserved characters: & / < > [ ]' ), $tag ); + if ( 0 !== preg_match( '@[<>&/\[\]\x00-\x20=]@', $tag ) ) { + /* translators: 1: shortcode name, 2: space separated list of reserved characters */ + $message = sprintf( __( 'Invalid shortcode name: %1$s. Do not use spaces or reserved characters: %2$s' ), $tag, '& / < > [ ] =' ); _doing_it_wrong( __FUNCTION__, $message, '4.4.0' ); return; } @@ -210,7 +210,7 @@ function do_shortcode( $content, $ignore_html = false ) { return $content; // Find all registered tag names in $content. - preg_match_all( '@\[([^<>&/\[\]\x00-\x20]++)@', $content, $matches ); + preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches ); $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); if ( empty( $tagnames ) ) { @@ -578,7 +578,7 @@ function strip_shortcodes( $content ) { return $content; // Find all registered tag names in $content. - preg_match_all( '@\[([^<>&/\[\]\x00-\x20]++)@', $content, $matches ); + preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches ); $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); if ( empty( $tagnames ) ) { diff --git a/tests/phpunit/tests/shortcode.php b/tests/phpunit/tests/shortcode.php index 65da789c25..7f92a6f242 100644 --- a/tests/phpunit/tests/shortcode.php +++ b/tests/phpunit/tests/shortcode.php @@ -647,4 +647,14 @@ EOF; } + /** + * @ticket 34939 + * + * Test the (not recommended) [shortcode=XXX] format + */ + function test_unnamed_attribute() { + $out = do_shortcode('[dumptag=https://wordpress.org/]'); + $expected = "0 = =https://wordpress.org\n"; + $this->assertEquals($expected, $out); + } }