Make WordPress Core


Ignore:
Timestamp:
03/01/2019 08:57:26 PM (6 years 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-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    r44309 r44785  
    115115        }
    116116
    117         $name       = basename( $file['file'] );
     117        $name       = wp_basename( $file['file'] );
    118118        $name_parts = pathinfo( $name );
    119119        $name       = trim( substr( $name, 0, -( 1 + strlen( $name_parts['extension'] ) ) ) );
     
    144144
    145145        if ( empty( $attachment->post_title ) ) {
    146             $attachment->post_title = preg_replace( '/\.[^.]+$/', '', basename( $file ) );
     146            $attachment->post_title = preg_replace( '/\.[^.]+$/', '', wp_basename( $file ) );
    147147        }
    148148
Note: See TracChangeset for help on using the changeset viewer.