mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Media: Remove accents in sanitize_file_name()
.
This brings some consistency with `sanitize_title()` and `sanitize_user()`. Props tar.gz, NumidWasNotAvailable, juliobox, p_enrique, cristovaov, zodiac1978, mikeschroder, markoheijnen, chriscct7, swissspidy, DrProtocols, pento, gitlost, joemcgill, dustinbolton, programmin, Vayu, MaximeCulea, lucasbustamante, nilovelez, RavanH, audrasjb, SergeyBiryukov. See #22363. Built from https://develop.svn.wordpress.org/trunk@48603 git-svn-id: http://core.svn.wordpress.org/trunk@48365 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f06efa4e29
commit
101d00601e
@ -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 );
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user