diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php
index 8cbe242..917ccef 100644
a
|
b
|
function wp_handle_sideload( &$file, $overrides = false, $time = null ) { |
471 | 471 | |
472 | 472 | $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); |
473 | 473 | |
474 | | // Strip the query strings. |
475 | | $filename = str_replace('?','-', $filename); |
476 | | $filename = str_replace('&','-', $filename); |
477 | | |
478 | 474 | // Move the file to the uploads dir |
479 | 475 | $new_file = $uploads['path'] . "/$filename"; |
480 | 476 | if ( false === @ rename( $file['tmp_name'], $new_file ) ) { |
diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
index 77ecbcd..b0768dd 100644
a
|
b
|
function sanitize_file_name( $filename ) { |
1021 | 1021 | $special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw ); |
1022 | 1022 | $filename = preg_replace( "#\x{00a0}#siu", ' ', $filename ); |
1023 | 1023 | $filename = str_replace($special_chars, '', $filename); |
| 1024 | $filename = str_replace( array( '%20', '+' ), '-', $filename); |
1024 | 1025 | $filename = preg_replace('/[\s-]+/', '-', $filename); |
1025 | 1026 | $filename = trim($filename, '.-_'); |
1026 | 1027 | |
diff --git a/tests/phpunit/tests/formatting/SanitizeFileName.php b/tests/phpunit/tests/formatting/SanitizeFileName.php
index e4f0824..2668275 100644
a
|
b
|
class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { |
19 | 19 | $this->assertEquals( 'testtest', sanitize_file_name( $string ) ); |
20 | 20 | } |
21 | 21 | |
| 22 | /** |
| 23 | * Test that spaces are correctly replaced with dashes. |
| 24 | * |
| 25 | * @ticket 16330 |
| 26 | */ |
| 27 | function test_replace_spaces() { |
| 28 | $string = "test %20+test -test"; |
| 29 | $this->assertEquals( 'test-test-test', sanitize_file_name( $string ) ); |
| 30 | } |
| 31 | |
22 | 32 | function test_replaces_any_number_of_hyphens_with_one_hyphen() { |
23 | 33 | $this->assertEquals("a-t-t", sanitize_file_name("a----t----t")); |
24 | 34 | } |