WordPress.org

Make WordPress Core

Ticket #50855: 50855.2.diff

File 50855.2.diff, 1.6 KB (added by boblinthorst, 3 months ago)
  • src/wp-includes/formatting.php

    diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
    index 238bcc738c..5aeb970d49 100644
    a b function sanitize_file_name( $filename ) { 
    20172017         */
    20182018        $special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw );
    20192019
    2020         $filename = str_replace( $special_chars, '', $filename );
    20212020        $filename = str_replace( array( '%20', '+' ), '-', $filename );
     2021        $filename = str_replace( $special_chars, '', $filename );
    20222022        $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename );
    20232023        $filename = trim( $filename, '.-_' );
    20242024
  • tests/phpunit/tests/formatting/SanitizeFileName.php

    diff --git a/tests/phpunit/tests/formatting/SanitizeFileName.php b/tests/phpunit/tests/formatting/SanitizeFileName.php
    index c14803311d..57b3b9b973 100644
    a b class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { 
    1717                        $string .= $char;
    1818                }
    1919                $string .= 'test';
    20                 $this->assertSame( 'testtest', sanitize_file_name( $string ) );
     20                $this->assertSame( 'test-test', sanitize_file_name( $string ) );
    2121        }
    2222
    2323        /**
    class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { 
    3838                $urls = array(
    3939                        'unencoded space.png'  => 'unencoded-space.png',
    4040                        'encoded-space.jpg'    => 'encoded-space.jpg',
    41                         'plus+space.jpg'       => 'plusspace.jpg',
    42                         'multi %20 +space.png' => 'multi-20-space.png',
     41                        'plus+space.jpg'       => 'plus-space.jpg',
     42                        'multi %20 +space.png' => 'multi-space.png',
    4343                );
    4444
    4545                foreach ( $urls as $test => $expected ) {