Make WordPress Core

Ticket #34939: 34939.diff

File 34939.diff, 3.0 KB (added by aaroncampbell, 9 years ago)
  • src/wp-includes/formatting.php

     
    216216
    217217        // Look for shortcodes and HTML elements.
    218218
    219         preg_match_all( '@\[/?([^<>&/\[\]\x00-\x20]++)@', $text, $matches );
     219        preg_match_all( '@\[/?([^<>&/\[\]\x00-\x20=]++)@', $text, $matches );
    220220        $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] );
    221221        $found_shortcodes = ! empty( $tagnames );
    222222        $shortcode_regex = $found_shortcodes ? _get_wptexturize_shortcode_regex( $tagnames ) : '';
  • src/wp-includes/shortcodes.php

     
    9595                return;
    9696        }
    9797
    98         if ( 0 !== preg_match( '@[<>&/\[\]\x00-\x20]@', $tag ) ) {
    99                 /* translators: %s: shortcode name */
    100                 $message = sprintf( __( 'Invalid shortcode name: %s. Do not use spaces or reserved characters: & / < > [ ]' ), $tag );
     98        if ( 0 !== preg_match( '@[<>&/\[\]\x00-\x20=]@', $tag ) ) {
     99                /* translators: 1: shortcode name, 2: space separated list of reserved characters */
     100                $message = sprintf( __( 'Invalid shortcode name: %1$s. Do not use spaces or reserved characters: %2$s' ), $tag, '& / < > [ ] =' );
    101101                _doing_it_wrong( __FUNCTION__, $message, '4.4.0' );
    102102                return;
    103103        }
     
    210210                return $content;
    211211
    212212        // Find all registered tag names in $content.
    213         preg_match_all( '@\[([^<>&/\[\]\x00-\x20]++)@', $content, $matches );
     213        preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches );
    214214        $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] );
    215215
    216216        if ( empty( $tagnames ) ) {
     
    312312        }
    313313
    314314        $tag = $m[2];
    315         $attr = shortcode_parse_atts( $m[3] );
     315        // Trim '=' from left side of attributes to handle shortcodes in the [shortcode=XXX] format (not a recommended format)
     316        $attr = shortcode_parse_atts( ltrim( $m[3], '=' ) );
    316317
    317318        if ( ! is_callable( $shortcode_tags[ $tag ] ) ) {
    318319                /* translators: %s: shortcode tag */
     
    578579                return $content;
    579580
    580581        // Find all registered tag names in $content.
    581         preg_match_all( '@\[([^<>&/\[\]\x00-\x20]++)@', $content, $matches );
     582        preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches );
    582583        $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] );
    583584
    584585        if ( empty( $tagnames ) ) {
  • tests/phpunit/tests/shortcode.php

     
    647647
    648648        }
    649649
     650        /**
     651         * @ticket 34939
     652         *
     653         * Test the (not recommended) [shortcode=XXX] format
     654         */
     655        function test_unnamed_attribute() {
     656                $out = do_shortcode('[dumptag=http://wordpress.com/]');
     657                $expected = "0 = http://wordpress.com\n";
     658                $this->assertEquals($expected, $out);
     659        }
    650660}