Make WordPress Core

Changeset 38673


Ignore:
Timestamp:
09/29/2016 01:20:10 AM (8 years ago)
Author:
joemcgill
Message:

Media: Use wp_basename() to create attachment titles from filenames.

In [38294], pathinfo() was used with the PATHINFO_BASENAME constant to
get the basename of the file to be used as an attachment title, which depends
on PHP locale and can cause issues with UTF-8 characters. This uses
wp_basename() instead, which is a more i18n-friendly version of basename().

Props SergeyBiryukov.
Fixes #37608, #37989.

File:
1 edited

Legend:

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

    r38672 r38673  
    284284        return new WP_Error( 'upload_error', $file['error'] );
    285285
    286     $name = pathinfo( $_FILES[$file_id]['name'], PATHINFO_FILENAME );
     286    $name = $_FILES[$file_id]['name'];
     287    $ext  = pathinfo( $name, PATHINFO_EXTENSION );
     288    $name = wp_basename( $name, ".$ext" );
    287289
    288290    $url = $file['url'];
Note: See TracChangeset for help on using the changeset viewer.