mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Anchor texturize to shortcodes to improve regex efficiency.
props miqrogroove. see #29557 for segfault issues. Built from https://develop.svn.wordpress.org/trunk@30449 git-svn-id: http://core.svn.wordpress.org/trunk@30443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a6103b30f5
commit
6e2f41a2a3
@ -28,7 +28,7 @@
|
||||
* @return string The string replaced with html entities
|
||||
*/
|
||||
function wptexturize($text, $reset = false) {
|
||||
global $wp_cockneyreplace;
|
||||
global $wp_cockneyreplace, $shortcode_tags;
|
||||
static $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements,
|
||||
$default_no_texturize_tags, $default_no_texturize_shortcodes, $run_texturize = true;
|
||||
|
||||
@ -205,6 +205,10 @@ function wptexturize($text, $reset = false) {
|
||||
|
||||
// Look for shortcodes and HTML elements.
|
||||
|
||||
$tagnames = array_keys( $shortcode_tags );
|
||||
$tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) );
|
||||
$tagregexp = "(?:$tagregexp)(?![\\w-])"; // Excerpt of get_shortcode_regex().
|
||||
|
||||
$comment_regex =
|
||||
'!' // Start of comment, after the <.
|
||||
. '(?:' // Unroll the loop: Consume everything until --> is found.
|
||||
@ -216,8 +220,12 @@ function wptexturize($text, $reset = false) {
|
||||
$shortcode_regex =
|
||||
'\[' // Find start of shortcode.
|
||||
. '[\/\[]?' // Shortcodes may begin with [/ or [[
|
||||
. '[^\s\/\[\]]' // No whitespace before name.
|
||||
. '[^\[\]]*+' // Shortcodes do not contain other shortcodes. Possessive critical.
|
||||
. $tagregexp // Only match registered shortcodes, because performance.
|
||||
. '(?:'
|
||||
. '[^\[\]<>]+' // Shortcodes do not contain other shortcodes. Quantifier critical.
|
||||
. '|'
|
||||
. '<[^\[\]>]*>' // HTML elements permitted. Prevents matching ] before >.
|
||||
. ')*+' // Possessive critical.
|
||||
. '\]' // Find end of shortcode.
|
||||
. '\]?'; // Shortcodes may end with ]]
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.1-beta1-30443';
|
||||
$wp_version = '4.1-beta1-30449';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user