From 0d0e2bf2badea8b5699aba397d9ea6e16150fcea Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Thu, 29 Sep 2016 01:20:10 +0000 Subject: [PATCH] Media: Use `wp_basename()` to create attachment titles from filenames. In [38294], `pathinfo()` was used with the `PATHINFO_BASENAME` constant to get the basename of the file to be used as an attachment title, which depends on PHP locale and can cause issues with UTF-8 characters. This uses `wp_basename()` instead, which is a more i18n-friendly version of `basename()`. Props SergeyBiryukov. Fixes #37608, #37989. git-svn-id: https://develop.svn.wordpress.org/trunk@38673 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/media.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index 9d63694031..a5d81d9a44 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -283,7 +283,9 @@ function media_handle_upload($file_id, $post_id, $post_data = array(), $override if ( isset($file['error']) ) return new WP_Error( 'upload_error', $file['error'] ); - $name = pathinfo( $_FILES[$file_id]['name'], PATHINFO_FILENAME ); + $name = $_FILES[$file_id]['name']; + $ext = pathinfo( $name, PATHINFO_EXTENSION ); + $name = wp_basename( $name, ".$ext" ); $url = $file['url']; $type = $file['type'];