~canonical-sysadmins/wordpress/4.7.1

« back to all changes in this revision

Viewing changes to wp-includes/formatting.php

  • Committer: Barry Price
  • Date: 2016-06-22 02:23:41 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: barry.price@canonical.com-20160622022341-9qrp2nesacwfx017
Merge WP4.5.3 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1364
1364
 * operating systems and special characters requiring special escaping
1365
1365
 * to manipulate at the command line. Replaces spaces and consecutive
1366
1366
 * dashes with a single dash. Trims period, dash and underscore from beginning
1367
 
 * and end of filename.
 
1367
 * and end of filename. It is not guaranteed that this function will return a
 
1368
 * filename that is allowed to be uploaded.
1368
1369
 *
1369
1370
 * @since 2.1.0
1370
1371
 *
1389
1390
        $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename );
1390
1391
        $filename = trim( $filename, '.-_' );
1391
1392
 
 
1393
        if ( false === strpos( $filename, '.' ) ) {
 
1394
                $mime_types = wp_get_mime_types();
 
1395
                $filetype = wp_check_filetype( 'test.' . $filename, $mime_types );
 
1396
                if ( $filetype['ext'] === $filename ) {
 
1397
                        $filename = 'unnamed-file.' . $filetype['ext'];
 
1398
                }
 
1399
        }
 
1400
 
1392
1401
        // Split the filename into a base and extension[s]
1393
1402
        $parts = explode('.', $filename);
1394
1403