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:
Aaron Jorbin
2019-03-01 20:57:26 +00:00
parent 4c45ff7c43
commit e421f262dc
32 changed files with 101 additions and 101 deletions
+3 -3
View File
@@ -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 );