Make WordPress Core

Changeset 36097


Ignore:
Timestamp:
12/26/2015 04:45:26 AM (9 years ago)
Author:
dd32
Message:

Shortcodes: = is a reserved character in shortcode names, mark it as such.

This allows for shortcodes such as [shortcode=attribute] to work, which while never intentionally supported were widely used in the pre-shortcode days.

Props aaroncampbell.
Fixes #34939 for trunk.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r36036 r36097  
    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 );
  • trunk/src/wp-includes/shortcodes.php

    r35982 r36097  
    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;
     
    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
     
    579579
    580580    // Find all registered tag names in $content.
    581     preg_match_all( '@\[([^<>&/\[\]\x00-\x20]++)@', $content, $matches );
     581    preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches );
    582582    $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] );
    583583
  • trunk/tests/phpunit/tests/shortcode.php

    r35244 r36097  
    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=https://wordpress.org/]');
     657        $expected = "0 = =https://wordpress.org\n";
     658        $this->assertEquals($expected, $out);
     659    }
    650660}
Note: See TracChangeset for help on using the changeset viewer.