Make WordPress Core


Ignore:
Timestamp:
07/24/2014 10:08:09 PM (11 years ago)
Author:
wonderboymusic
Message:

In sanitize_file_name(), replace %20 and + with dashes. Remove unnecessary code from _wp_handle_upload().

Adds unit tests.

Props ericmann.
Fixes #16330.

File:
1 edited

Legend:

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

    r25002 r29290  
    2020    }
    2121
     22    /**
     23     * Test that spaces are correctly replaced with dashes.
     24     *
     25     * @ticket 16330
     26     */
     27    function test_replace_spaces() {
     28        $urls = array(
     29            'unencoded space.png'   => 'unencoded-space.png',
     30            'encoded%20space.jpg'   => 'encoded-space.jpg',
     31            'plus+space.jpg'        => 'plus-space.jpg',
     32            'multi %20 +space.png'   => 'multi-space.png',
     33        );
     34
     35        foreach( $urls as $test => $expected ) {
     36            $this->assertEquals( $expected, sanitize_file_name( $test ) );
     37        }
     38    }
     39
    2240    function test_replaces_any_number_of_hyphens_with_one_hyphen() {
    2341        $this->assertEquals("a-t-t", sanitize_file_name("a----t----t"));
Note: See TracChangeset for help on using the changeset viewer.