diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 7c1839fa92..d55a6bd538 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -447,6 +447,9 @@ function sanitize_user( $username, $strict = false ) { if ( $strict ) $username = preg_replace('|[^a-z0-9 _.\-@]|i', '', $username); + // Consolidate contiguous whitespace + $username = preg_replace('|\s+|', ' ', $username); + return apply_filters('sanitize_user', $username, $raw_username, $strict); }