WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/01/2019 08:57:26 PM (10 months ago)
Author:
jorbin
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/image.php

    r44566 r44785  
    4848
    4949    if ( ! $dst_file ) {
    50         $dst_file = str_replace( basename( $src_file ), 'cropped-' . basename( $src_file ), $src_file );
     50        $dst_file = str_replace( wp_basename( $src_file ), 'cropped-' . wp_basename( $src_file ), $src_file );
    5151    }
    5252
     
    5757    wp_mkdir_p( dirname( $dst_file ) );
    5858
    59     $dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) );
     59    $dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), wp_basename( $dst_file ) );
    6060
    6161    $result = $editor->save( $dst_file );
     
    190190                    break;
    191191            }
    192             $basename = str_replace( '.', '-', basename( $file ) ) . '-image' . $ext;
     192            $basename = str_replace( '.', '-', wp_basename( $file ) ) . '-image' . $ext;
    193193            $uploaded = wp_upload_bits( $basename, '', $metadata['image']['data'] );
    194194            if ( false === $uploaded['error'] ) {
     
    712712
    713713    if ( $src_file ) {
    714         $dst_file = str_replace( basename( $dst_file ), 'copy-' . basename( $dst_file ), $dst_file );
    715         $dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) );
     714        $dst_file = str_replace( wp_basename( $dst_file ), 'copy-' . wp_basename( $dst_file ), $dst_file );
     715        $dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), wp_basename( $dst_file ) );
    716716
    717717        /*
Note: See TracChangeset for help on using the changeset viewer.