mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-03 22:27:04 +00:00
Replace usages of basename() with wp_basename() in order to support multibyte filenames
This is focused on the pieces of code that touch media files and the tests that support them. `basename` isn't multibyte compatible out of the box. See http://php.net/basename and https://bugs.php.net/bug.php?id=62119. See #43170. Props Viper007Bond. git-svn-id: https://develop.svn.wordpress.org/trunk@44785 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -434,7 +434,7 @@ function media_handle_sideload( $file_array, $post_id, $desc = null, $post_data
|
||||
$url = $file['url'];
|
||||
$type = $file['type'];
|
||||
$file = $file['file'];
|
||||
$title = preg_replace( '/\.[^.]+$/', '', basename( $file ) );
|
||||
$title = preg_replace( '/\.[^.]+$/', '', wp_basename( $file ) );
|
||||
$content = '';
|
||||
|
||||
// Use image exif/iptc data for title and caption defaults if possible.
|
||||
@@ -826,7 +826,7 @@ function wp_media_upload_handler() {
|
||||
if ( isset( $_POST['media_type'] ) && 'image' != $_POST['media_type'] ) {
|
||||
$title = esc_html( wp_unslash( $_POST['title'] ) );
|
||||
if ( empty( $title ) ) {
|
||||
$title = esc_html( basename( $src ) );
|
||||
$title = esc_html( wp_basename( $src ) );
|
||||
}
|
||||
|
||||
if ( $title && $src ) {
|
||||
@@ -930,7 +930,7 @@ function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' )
|
||||
}
|
||||
|
||||
$file_array = array();
|
||||
$file_array['name'] = basename( $matches[0] );
|
||||
$file_array['name'] = wp_basename( $matches[0] );
|
||||
|
||||
// Download file to temp location.
|
||||
$file_array['tmp_name'] = download_url( $file );
|
||||
|
||||
Reference in New Issue
Block a user