Make WordPress Core

Ticket #9405: 9405.3.diff

File 9405.3.diff, 1.6 KB (added by aaroncampbell, 11 years ago)
  • src/wp-includes/shortcodes.php

     
    308308 */
    309309function shortcode_parse_atts($text) {
    310310        $atts = array();
    311         $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
     311        $pattern = '/([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*\'([^\']*)\'(?:\s|$)|([\w-]+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
    312312        $text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text);
    313313        if ( preg_match_all($pattern, $text, $match, PREG_SET_ORDER) ) {
    314314                foreach ($match as $m) {
  • tests/phpunit/tests/shortcode.php

     
    119119                $this->assertEquals( '[hyphen-foo-bar-baz]', do_shortcode( '[hyphen-foo-bar-baz]' ) );
    120120        }
    121121
     122        /**
     123         * @ticket 9405
     124         */
     125        function test_attr_hyphen() {
     126                do_shortcode('[test-shortcode-tag foo="foo" foo-bar="foo-bar" foo-bar-="foo-bar-" -foo-bar="-foo-bar" -foo-bar-="-foo-bar-" /]');
     127                $expected_attrs = array(
     128                        'foo' => 'foo',
     129                        'foo-bar' => 'foo-bar',
     130                        'foo-bar-' => 'foo-bar-',
     131                        '-foo-bar' => '-foo-bar',
     132                        '-foo-bar-' => '-foo-bar-',
     133                );
     134                $this->assertEquals( $expected_attrs, $this->atts );
     135        }
     136
    122137        function test_two_atts() {
    123138                do_shortcode('[test-shortcode-tag foo="asdf" bar="bing" /]');
    124139                $this->assertEquals( array('foo' => 'asdf', 'bar' => 'bing'), $this->atts );