Use less greedy regex in `wptexturize()`. Adds unit tests.

Props miqrogroove.
See #28564.

Built from https://develop.svn.wordpress.org/trunk@28852


git-svn-id: http://core.svn.wordpress.org/trunk@28656 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-06-26 17:15:14 +00:00
parent 1c227553b9
commit 9997f77d7f
1 changed files with 4 additions and 4 deletions

View File

@ -198,7 +198,7 @@ function wptexturize($text, $reset = false) {
. '(?(?=!--)' // Is this a comment?
. '.+?--\s*>' // Find end of comment
. '|'
. '.+?>' // Find end of element
. '[^>]+>' // Find end of element
. ')'
. '|'
. '\[' // Find start of shortcode.
@ -206,7 +206,7 @@ function wptexturize($text, $reset = false) {
. '(?:'
. '[^\[\]<>]' // Shortcodes do not contain other shortcodes.
. '|'
. '<.+?>' // HTML elements permitted. Prevents matching ] before >.
. '<[^>]+>' // HTML elements permitted. Prevents matching ] before >.
. ')+'
. '\]' // Find end of shortcode.
. '\]?' // Shortcodes may end with ]]
@ -224,12 +224,12 @@ function wptexturize($text, $reset = false) {
_wptexturize_pushpop_element( $curl, $no_texturize_tags_stack, $no_texturize_tags );
}
} elseif ( '[' === $first && 1 === preg_match( '/^\[(?:[^\[\]<>]|<.+?>)+\]$/', $curl ) ) {
} elseif ( '[' === $first && 1 === preg_match( '/^\[(?:[^\[\]<>]|<[^>]+>)+\]$/', $curl ) ) {
// This is a shortcode delimeter.
_wptexturize_pushpop_element( $curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes );
} elseif ( '[' === $first && 1 === preg_match( '/^\[\[?(?:[^\[\]<>]|<.+?>)+\]\]?$/', $curl ) ) {
} elseif ( '[' === $first && 1 === preg_match( '/^\[\[?(?:[^\[\]<>]|<[^>]+>)+\]\]?$/', $curl ) ) {
// This is an escaped shortcode delimeter.
// Do not texturize.