From ad0b20ad098a64f5412c983aafe41a192aefd408 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 7 Sep 2014 08:32:22 +0000 Subject: [PATCH] Check for [\r\n\t ] instead of \s in sanitize_file_name() to avoid UTF-8 issues. props p_enrique. fixes #26094. git-svn-id: https://develop.svn.wordpress.org/trunk@29715 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/formatting.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 1f18ab9d91..4daeba9a44 100644 --- a/src/wp-includes/formatting.php +++ b/src/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);