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/includes/media.php

    r44634 r44785  
    435435    $type    = $file['type'];
    436436    $file    = $file['file'];
    437     $title   = preg_replace( '/\.[^.]+$/', '', basename( $file ) );
     437    $title   = preg_replace( '/\.[^.]+$/', '', wp_basename( $file ) );
    438438    $content = '';
    439439
     
    827827            $title = esc_html( wp_unslash( $_POST['title'] ) );
    828828            if ( empty( $title ) ) {
    829                 $title = esc_html( basename( $src ) );
     829                $title = esc_html( wp_basename( $src ) );
    830830            }
    831831
     
    931931
    932932        $file_array         = array();
    933         $file_array['name'] = basename( $matches[0] );
     933        $file_array['name'] = wp_basename( $matches[0] );
    934934
    935935        // Download file to temp location.
Note: See TracChangeset for help on using the changeset viewer.