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 ) { |
| 2017 | 2017 | */ |
| 2018 | 2018 | $special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw ); |
| 2019 | 2019 | |
| 2020 | | $filename = str_replace( $special_chars, '', $filename ); |
| 2021 | 2020 | $filename = str_replace( array( '%20', '+' ), '-', $filename ); |
| | 2021 | $filename = str_replace( $special_chars, '', $filename ); |
| 2022 | 2022 | $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename ); |
| 2023 | 2023 | $filename = trim( $filename, '.-_' ); |
| 2024 | 2024 | |
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 { |
| 17 | 17 | $string .= $char; |
| 18 | 18 | } |
| 19 | 19 | $string .= 'test'; |
| 20 | | $this->assertSame( 'testtest', sanitize_file_name( $string ) ); |
| | 20 | $this->assertSame( 'test-test', sanitize_file_name( $string ) ); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
| … |
… |
class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { |
| 38 | 38 | $urls = array( |
| 39 | 39 | 'unencoded space.png' => 'unencoded-space.png', |
| 40 | 40 | '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', |
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | 45 | foreach ( $urls as $test => $expected ) { |