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
This commit is contained in:
parent
aec63aa377
commit
b47a03278e
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue