Changeset 34933
- Timestamp:
- 10/08/2015 03:11:59 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
src/wp-includes/js/shortcode.js (modified) (1 diff)
-
src/wp-includes/shortcodes.php (modified) (2 diffs)
-
tests/phpunit/tests/shortcode.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/shortcode.js
r30695 r34933 136 136 // 7. A numeric attribute in double quotes. 137 137 // 8. An unquoted numeric attribute. 138 pattern = /( \w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/g;138 pattern = /([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/g; 139 139 140 140 // Map zero-width spaces to actual spaces. -
trunk/src/wp-includes/shortcodes.php
r34868 r34933 452 452 453 453 /** 454 * Retrieve the shortcode attributes regex. 455 * 456 * @since 4.4.0 457 * 458 * @return string The shortcode attribute regular expression 459 */ 460 function get_shortcode_atts_regex() { 461 return '/([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*\'([^\']*)\'(?:\s|$)|([\w-]+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/'; 462 } 463 464 /** 454 465 * Retrieve all attributes from the shortcodes tag. 455 466 * … … 468 479 function shortcode_parse_atts($text) { 469 480 $atts = array(); 470 $pattern = '/([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*\'([^\']*)\'(?:\s|$)|([\w-]+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';481 $pattern = get_shortcode_atts_regex(); 471 482 $text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text); 472 483 if ( preg_match_all($pattern, $text, $match, PREG_SET_ORDER) ) { -
trunk/tests/phpunit/tests/shortcode.php
r34774 r34933 633 633 return data_whole_posts(); 634 634 } 635 636 function test_php_and_js_shortcode_attribute_regexes_match() { 637 638 $file = file_get_contents( ABSPATH . WPINC . '/js/shortcode.js' ); 639 $matched = preg_match( '|\s+pattern = (\/.+\/)g;|', $file, $matches ); 640 $php = get_shortcode_atts_regex(); 641 642 $this->assertSame( 1, $matched ); 643 644 $js = str_replace( "\'", "'", $matches[1] ); 645 $this->assertSame( $php, $js ); 646 647 } 648 635 649 }
Note: See TracChangeset
for help on using the changeset viewer.