Changeset 29290
- Timestamp:
- 07/24/2014 10:08:09 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/file.php
r29209 r29290 328 328 329 329 $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); 330 // Strip the query strings.331 $filename = str_replace( '?', '-', $filename );332 $filename = str_replace( '&', '-', $filename );333 330 334 331 // Move the file to the uploads dir. -
trunk/src/wp-includes/formatting.php
r29163 r29290 1050 1050 $filename = preg_replace( "#\x{00a0}#siu", ' ', $filename ); 1051 1051 $filename = str_replace($special_chars, '', $filename); 1052 $filename = str_replace( array( '%20', '+' ), '-', $filename ); 1052 1053 $filename = preg_replace('/[\s-]+/', '-', $filename); 1053 1054 $filename = trim($filename, '.-_'); -
trunk/tests/phpunit/tests/formatting/SanitizeFileName.php
r25002 r29290 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 $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 22 40 function test_replaces_any_number_of_hyphens_with_one_hyphen() { 23 41 $this->assertEquals("a-t-t", sanitize_file_name("a----t----t"));
Note: See TracChangeset
for help on using the changeset viewer.