From 93903a2a811e4e2dd659d6857e2e9ed450b13825 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 7 Sep 2014 08:33:16 +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. Built from https://develop.svn.wordpress.org/trunk@29715 git-svn-id: http://core.svn.wordpress.org/trunk@29489 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/formatting.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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);