From bcf98c77421134dca82a2a5ab76986d041707bec Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 1 Apr 2015 19:08:31 +0000 Subject: [PATCH] Alter the regex in `wptexturize()` to properly handle input like: `<> "Hello world" <>`. Updates unit test data. Props miqrogroove. Fixes #30344. git-svn-id: https://develop.svn.wordpress.org/trunk@31965 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/formatting.php | 2 +- tests/phpunit/tests/formatting/WPTexturize.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 74537c1065..762637a320 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -235,7 +235,7 @@ function wptexturize($text, $reset = false) { . '(?(?=!--)' // Is this a comment? . $comment_regex // Find end of comment. . '|' - . '[^>]+>' // Find end of element. + . '[^>]*>' // Find end of element. . ')' . '|' . $shortcode_regex // Find shortcodes. diff --git a/tests/phpunit/tests/formatting/WPTexturize.php b/tests/phpunit/tests/formatting/WPTexturize.php index f69260322f..0eb08e2ed4 100644 --- a/tests/phpunit/tests/formatting/WPTexturize.php +++ b/tests/phpunit/tests/formatting/WPTexturize.php @@ -1393,6 +1393,18 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { '[Let\'s get crazy[caption code="hello"]world]', // caption shortcode is invalid here because it contains [] chars. '[Let’s get crazy[caption code=”hello“]world]', ), + array( + '<> ... <>', + '<> … <>', + ), + array( + '<> ... <> ... >', + '<> … <> … >', + ), + array( + '<> ... < ... > ... <>', + '<> … < ... > … <>', + ), ); }