Make WordPress Core

Ticket #23307: 23307.2.diff

File 23307.2.diff, 1.9 KB (added by aaroncampbell, 10 years ago)
  • src/wp-includes/shortcodes.php

    diff --git src/wp-includes/shortcodes.php src/wp-includes/shortcodes.php
    index 9874785..1416024 100644
    function do_shortcode_tag( $m ) { 
    306306 * @return array List of attributes and their value.
    307307 */
    308308function shortcode_parse_atts($text) {
     309        if ( empty( trim( $text ) ) ) {
     310                return array();
     311        }
    309312        $atts = array();
    310313        $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
    311314        $text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text);
    function shortcode_parse_atts($text) { 
    323326                                $atts[] = stripcslashes($m[8]);
    324327                }
    325328        } else {
    326                 $atts = ltrim($text);
     329                $atts[] = ltrim( $text );
    327330        }
    328331        return $atts;
    329332}
  • tests/phpunit/tests/shortcode.php

    diff --git tests/phpunit/tests/shortcode.php tests/phpunit/tests/shortcode.php
    index 7e8b971..5273eea 100644
    class Tests_Shortcode extends WP_UnitTestCase { 
    7575
    7676        function test_noatts() {
    7777                do_shortcode('[test-shortcode-tag /]');
    78                 $this->assertEquals( '', $this->atts );
     78                $this->assertEmpty( $this->atts );
    7979                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    8080        }
    8181
    class Tests_Shortcode extends WP_UnitTestCase { 
    127127
    128128        function test_noatts_enclosing() {
    129129                do_shortcode('[test-shortcode-tag]content[/test-shortcode-tag]');
    130                 $this->assertEquals( '', $this->atts );
     130                $this->assertEmpty( $this->atts );
    131131                $this->assertEquals( 'content', $this->content );
    132132                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    133133        }
    class Tests_Shortcode extends WP_UnitTestCase { 
    149149        function test_unclosed() {
    150150                $out = do_shortcode('[test-shortcode-tag]');
    151151                $this->assertEquals( '', $out );
    152                 $this->assertEquals( '', $this->atts );
     152                $this->assertEmpty( $this->atts );
    153153                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    154154        }
    155155