Ticket #32172: 32172.patch
File 32172.patch, 2.3 KB (added by , 10 years ago) |
---|
-
src/wp-includes/shortcodes.php
304 304 */ 305 305 function shortcode_parse_atts($text) { 306 306 $atts = array(); 307 $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)| (\S+)(?:\s|$)/';307 $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|\'([^\']*)\'(?:\s|$)|(\S+)(?:\s|$)/'; 308 308 $text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text); 309 309 if ( preg_match_all($pattern, $text, $match, PREG_SET_ORDER) ) { 310 310 foreach ($match as $m) { … … 316 316 $atts[strtolower($m[5])] = stripcslashes($m[6]); 317 317 elseif (isset($m[7]) && strlen($m[7])) 318 318 $atts[] = stripcslashes($m[7]); 319 elseif (isset($m[8]) )319 elseif (isset($m[8]) && strlen($m[8])) 320 320 $atts[] = stripcslashes($m[8]); 321 elseif (isset($m[9])) 322 $atts[] = stripcslashes($m[9]); 321 323 } 322 324 } else { 323 325 $atts = ltrim($text); -
tests/phpunit/tests/shortcode.php
188 188 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 189 189 } 190 190 191 /** 192 * @ticket 32172 193 */ 194 function test_positional_atts_single_quotes() { 195 $out = do_shortcode("[test-shortcode-tag 'something in quotes' 'something else']"); 196 $this->assertEquals( '', $out ); 197 $this->assertEquals( array(0=>'something in quotes', 1=>'something else'), $this->atts ); 198 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 199 } 200 201 /** 202 * @ticket 32172 203 */ 204 function test_positional_atts_mixed_quotes() { 205 $out = do_shortcode("[test-shortcode-tag 'something in quotes' \"something else\" 123 foo bar='baz' example=\"test\" ]"); 206 $this->assertEquals( '', $out ); 207 $this->assertEquals( array(0=>'something in quotes', 1=>'something else', 2 => '123', 3 => 'foo', 'bar' => 'baz', 'example' => 'test'), $this->atts ); 208 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 209 } 210 191 211 function test_footag_default() { 192 212 $out = do_shortcode('[footag]'); 193 213 $this->assertEquals('foo = ', $out);