diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index 381ca1cd64..c38a6a40f1 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -327,9 +327,6 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) { } $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); - // Strip the query strings. - $filename = str_replace( '?', '-', $filename ); - $filename = str_replace( '&', '-', $filename ); // Move the file to the uploads dir. $new_file = $uploads['path'] . "/$filename"; diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index c858aac78a..2a01ea8db2 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -1049,6 +1049,7 @@ 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( array( '%20', '+' ), '-', $filename ); $filename = preg_replace('/[\s-]+/', '-', $filename); $filename = trim($filename, '.-_');