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. Built from https://develop.svn.wordpress.org/trunk@44785 git-svn-id: http://core.svn.wordpress.org/trunk@44617 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -114,7 +114,7 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
|
||||
return $file;
|
||||
}
|
||||
|
||||
$name = basename( $file['file'] );
|
||||
$name = wp_basename( $file['file'] );
|
||||
$name_parts = pathinfo( $name );
|
||||
$name = trim( substr( $name, 0, -( 1 + strlen( $name_parts['extension'] ) ) ) );
|
||||
|
||||
@@ -143,7 +143,7 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
|
||||
$attachment->guid = $url;
|
||||
|
||||
if ( empty( $attachment->post_title ) ) {
|
||||
$attachment->post_title = preg_replace( '/\.[^.]+$/', '', basename( $file ) );
|
||||
$attachment->post_title = preg_replace( '/\.[^.]+$/', '', wp_basename( $file ) );
|
||||
}
|
||||
|
||||
// $post_parent is inherited from $attachment['post_parent'].
|
||||
|
||||
Reference in New Issue
Block a user