Abstract the shortcode attribute parsing regex into its own function, update the JavaScript counterpart, and introduce a test to ensure they do not diverge again.

Fixes #34191
Props miqrogroove, johnbillion


git-svn-id: https://develop.svn.wordpress.org/trunk@34933 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn
2015-10-08 03:11:59 +00:00
parent 9b156ee2a9
commit ba7dc01639
3 changed files with 27 additions and 2 deletions

View File

@@ -632,4 +632,18 @@ EOF;
require_once( DIR_TESTDATA . '/formatting/whole-posts.php' );
return data_whole_posts();
}
function test_php_and_js_shortcode_attribute_regexes_match() {
$file = file_get_contents( ABSPATH . WPINC . '/js/shortcode.js' );
$matched = preg_match( '|\s+pattern = (\/.+\/)g;|', $file, $matches );
$php = get_shortcode_atts_regex();
$this->assertSame( 1, $matched );
$js = str_replace( "\'", "'", $matches[1] );
$this->assertSame( $php, $js );
}
}