diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 1f18ab9d91..4daeba9a44 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -1054,10 +1054,10 @@ function sanitize_file_name( $filename ) { */ $special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw ); $filename = preg_replace( "#\x{00a0}#siu", ' ', $filename ); - $filename = str_replace($special_chars, '', $filename); + $filename = str_replace( $special_chars, '', $filename ); $filename = str_replace( array( '%20', '+' ), '-', $filename ); - $filename = preg_replace('/[\s-]+/', '-', $filename); - $filename = trim($filename, '.-_'); + $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename ); + $filename = trim( $filename, '.-_' ); // Split the filename into a base and extension[s] $parts = explode('.', $filename);