Make WordPress Core


Ignore:
Timestamp:
06/21/2016 01:43:59 PM (8 years ago)
Author:
joemcgill
Message:

Media: Improve handling of extensionless filenames.

This ensures files retain a filename after sanitization.

Fixes 37111.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/formatting/SanitizeFileName.php

    r35122 r37756  
    5757        $this->assertEquals( 'a22b.jpg', sanitize_file_name( 'a%22b.jpg' ) );
    5858    }
     59
     60    function test_replaces_unnammed_file_extensions() {
     61        // Test filenames with both supported and unsupported extensions.
     62        $this->assertEquals( 'unnamed-file.exe', sanitize_file_name( '_.exe' ) );
     63        $this->assertEquals( 'unnamed-file.jpg', sanitize_file_name( '_.jpg' ) );
     64    }
     65
     66    function test_replaces_unnammed_file_extensionless() {
     67        // Test a filenames that becomes extensionless.
     68        $this->assertEquals( 'no-extension', sanitize_file_name( '_.no-extension' ) );
     69    }
    5970}
Note: See TracChangeset for help on using the changeset viewer.