Skip to content

Commit

Permalink
Media: Use wp_basename() to create attachment titles from filenames.
Browse files Browse the repository at this point in the history
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.
Built from https://develop.svn.wordpress.org/trunk@38673


git-svn-id: http://core.svn.wordpress.org/trunk@38616 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
joemcgill committed Sep 29, 2016
1 parent eeefec9 commit 498040b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion wp-admin/includes/media.php
Expand Up @@ -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'];
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Expand Up @@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-alpha-38672';
$wp_version = '4.7-alpha-38673';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit 498040b

Please sign in to comment.