Make WordPress Core


Ignore:
Timestamp:
06/21/2016 02:57:23 PM (10 years ago)
Author:
joemcgill
Message:

Media: Improve handling of extensionless filenames.

Merge of [37756] to the 4.0 branch.

See #37111.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0/src/wp-includes/formatting.php

    r33522 r37819  
    11511151 * to manipulate at the command line. Replaces spaces and consecutive
    11521152 * dashes with a single dash. Trims period, dash and underscore from beginning
    1153  * and end of filename.
     1153 * and end of filename. It is not guaranteed that this function will return a
     1154 * filename that is allowed to be uploaded.
    11541155 *
    11551156 * @since 2.1.0
     
    11751176    $filename = preg_replace('/[\s-]+/', '-', $filename);
    11761177    $filename = trim($filename, '.-_');
     1178
     1179    if ( false === strpos( $filename, '.' ) ) {
     1180        $mime_types = wp_get_mime_types();
     1181        $filetype = wp_check_filetype( 'test.' . $filename, $mime_types );
     1182        if ( $filetype['ext'] === $filename ) {
     1183            $filename = 'unnamed-file.' . $filetype['ext'];
     1184        }
     1185    }
    11771186
    11781187    // Split the filename into a base and extension[s]
Note: See TracChangeset for help on using the changeset viewer.