diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index a85f14f014..d031656d43 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -1984,7 +1984,9 @@ function remove_accents( $string ) { * @return string The sanitized filename. */ function sanitize_file_name( $filename ) { - $filename_raw = $filename; + $filename_raw = $filename; + $filename = remove_accents( $filename ); + $special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', '’', '«', '»', '”', '“', chr( 0 ) ); // Check for support for utf8 in the installed PCRE library once and store the result in a static. @@ -2013,10 +2015,11 @@ function sanitize_file_name( $filename ) { * @param string $filename_raw The original filename to be sanitized. */ $special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw ); - $filename = str_replace( $special_chars, '', $filename ); - $filename = str_replace( array( '%20', '+' ), '-', $filename ); - $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename ); - $filename = trim( $filename, '.-_' ); + + $filename = str_replace( $special_chars, '', $filename ); + $filename = str_replace( array( '%20', '+' ), '-', $filename ); + $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename ); + $filename = trim( $filename, '.-_' ); if ( false === strpos( $filename, '.' ) ) { $mime_types = wp_get_mime_types(); @@ -2068,7 +2071,9 @@ function sanitize_file_name( $filename ) { } } } + $filename .= '.' . $extension; + /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'sanitize_file_name', $filename, $filename_raw ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index ed0d0641de..330420d561 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-beta3-48602'; +$wp_version = '5.5-beta3-48603'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.