WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/01/2019 08:57:26 PM (6 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/custom-header.php

    r44574 r44785  
    821821        } elseif ( $width > $max_width ) {
    822822            $oitar = $width / $max_width;
    823             $image = wp_crop_image( $attachment_id, 0, 0, $width, $height, $max_width, $height / $oitar, false, str_replace( basename( $file ), 'midsize-' . basename( $file ), $file ) );
     823            $image = wp_crop_image( $attachment_id, 0, 0, $width, $height, $max_width, $height / $oitar, false, str_replace( wp_basename( $file ), 'midsize-' . wp_basename( $file ), $file ) );
    824824            if ( ! $image || is_wp_error( $image ) ) {
    825825                wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) );
     
    829829            $image = apply_filters( 'wp_create_file_in_uploads', $image, $attachment_id ); // For replication
    830830
    831             $url    = str_replace( basename( $url ), basename( $image ), $url );
     831            $url    = str_replace( wp_basename( $url ), wp_basename( $image ), $url );
    832832            $width  = $width / $oitar;
    833833            $height = $height / $oitar;
     
    896896        $type     = $file['type'];
    897897        $file     = $file['file'];
    898         $filename = basename( $file );
     898        $filename = wp_basename( $file );
    899899
    900900        // Construct the object array
     
    985985
    986986        // Cleanup.
    987         $medium = str_replace( basename( $original ), 'midsize-' . basename( $original ), $original );
     987        $medium = str_replace( wp_basename( $original ), 'midsize-' . wp_basename( $original ), $original );
    988988        if ( file_exists( $medium ) ) {
    989989            wp_delete_file( $medium );
     
    12091209        $parent     = get_post( $parent_attachment_id );
    12101210        $parent_url = wp_get_attachment_url( $parent->ID );
    1211         $url        = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
     1211        $url        = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url );
    12121212
    12131213        $size       = @getimagesize( $cropped );
     
    12161216        $object = array(
    12171217            'ID'             => $parent_attachment_id,
    1218             'post_title'     => basename( $cropped ),
     1218            'post_title'     => wp_basename( $cropped ),
    12191219            'post_mime_type' => $image_type,
    12201220            'guid'           => $url,
Note: See TracChangeset for help on using the changeset viewer.