From 7d9a46e01c7b6e2aa5f1e09a7663672d24c39eed Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Wed, 23 Dec 2009 11:00:29 +0000 Subject: [PATCH] Only run a second spaces strip if we replaced some octets. Also only replace spaces and we have already removed the other whitespace chars. Fixes #11573 props azaozz. git-svn-id: https://develop.svn.wordpress.org/trunk@12504 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/formatting.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 8b2d999dc2..246a5a3937 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -2841,11 +2841,16 @@ function sanitize_text_field($str) { } $match = array(); + $found = false; while ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) { $filtered = str_replace($match[0], '', $filtered); + $found = true; + } + + if ( $found ) { + // Strip out the whitespace that may now exist after removing the octets. + $filtered = trim( preg_replace('/ +/', ' ', $filtered) ); } - // Strip out the whitespace that may now exist after removing the octets. - $filtered = trim( preg_replace('/[\r\n\t ]+/', ' ', $filtered) ); return apply_filters('sanitize_text_field', $filtered, $str); }