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
This commit is contained in:
Sergey Biryukov 2014-09-07 08:33:16 +00:00
parent cc04e76d11
commit 93903a2a81
1 changed files with 3 additions and 3 deletions

View File

@ -1054,10 +1054,10 @@ function sanitize_file_name( $filename ) {
*/ */
$special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw ); $special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw );
$filename = preg_replace( "#\x{00a0}#siu", ' ', $filename ); $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 = str_replace( array( '%20', '+' ), '-', $filename );
$filename = preg_replace('/[\s-]+/', '-', $filename); $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename );
$filename = trim($filename, '.-_'); $filename = trim( $filename, '.-_' );
// Split the filename into a base and extension[s] // Split the filename into a base and extension[s]
$parts = explode('.', $filename); $parts = explode('.', $filename);