From b47a03278e08f45ae8a8be668e554aaad71b0d2e Mon Sep 17 00:00:00 2001 From: westi 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: http://svn.automattic.com/wordpress/trunk@12504 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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 8b2d999dc..246a5a393 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); }