Ticket #22363: 22363.12.patch
File 22363.12.patch, 4.2 KB (added by , 9 years ago) |
---|
-
src/wp-includes/default-filters.php
197 197 add_filter( 'teeny_mce_before_init', '_mce_set_direction' ); 198 198 add_filter( 'pre_kses', 'wp_pre_kses_less_than' ); 199 199 add_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10, 3 ); 200 add_filter( 'sanitize_file_name', 'remove_accents' ); 200 201 add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 3 ); 201 202 add_filter( 'comment_flood_filter', 'wp_throttle_comment_flood', 10, 3 ); 202 203 add_filter( 'pre_comment_content', 'wp_rel_nofollow', 15 ); -
src/wp-includes/formatting.php
1764 1764 * @param string $filename_raw Filename as it was passed into sanitize_file_name(). 1765 1765 */ 1766 1766 $special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw ); 1767 $filename = preg_replace( "#\x{00a0}#siu", ' ', $filename );1768 1767 $filename = str_replace( $special_chars, '', $filename ); 1769 $filename = str_replace( array( '%20', '+' ), '-', $filename ); 1768 if ( ! seems_utf8( $filename ) ) { 1769 // Reduce to ASCII. 1770 $filename = preg_replace( '/[\x80-\xff]/', '-', $filename ); 1771 } 1772 $filename = str_replace( array( '%20', '+', "\xc2\xa0" ), '-', $filename ); 1770 1773 $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename ); 1771 1774 $filename = trim( $filename, '.-_' ); 1772 1775 -
tests/phpunit/tests/formatting/SanitizeFileName.php
47 47 48 48 function test_replaces_any_amount_of_whitespace_with_one_hyphen() { 49 49 $this->assertEquals("a-t", sanitize_file_name("a t")); 50 $this->assertEquals("a-t", sanitize_file_name("a \ n\n\nt"));50 $this->assertEquals("a-t", sanitize_file_name("a \t\r\n\n\nt")); 51 51 } 52 52 53 53 /** … … 67 67 // Test a filenames that becomes extensionless. 68 68 $this->assertEquals( 'no-extension', sanitize_file_name( '_.no-extension' ) ); 69 69 } 70 71 /** 72 * @ticket 22363 73 */ 74 function test_replaces_utf8_whitespace() { 75 $this->assertEquals("non-breaking", sanitize_file_name("non\xc2\xa0breaking")); 76 } 77 78 /** 79 * @ticket 22363 80 */ 81 function test_replaces_accents() { 82 $in = 'àáâãäåæçèéêëìíîïñòóôõöøùúûüýÿ'; 83 $out = 'aaaaaaaeceeeeiiiinoooooouuuuyy'; 84 $this->assertEquals( $out, sanitize_file_name( $in ) ); 85 } 86 87 /** 88 * @ticket 22363 89 * @ticket 24661 90 */ 91 /* Requires #24661 fix 92 function test_replaces_combining_accents() { 93 $in = 'àáâãäåçèéêëìíîïñòóôõöùúûüýÿ'; 94 $out = 'aaaaaaceeeeiiiinooooouuuuyy'; 95 $this->assertEquals( $out, sanitize_file_name( $in ) ); 96 } 97 */ 98 99 /** 100 * @ticket 22363 101 */ 102 function test_strips_non_alpha_html_entities() { 103 $this->assertEquals("start-copy-amp-euro-ndash-nbsp-end", sanitize_file_name( "start © & € – end" ) ); 104 $this->assertEquals("start-invalid-end", sanitize_file_name( "start &invalid; end" ) ); 105 } 106 107 /** 108 * @ticket 22363 109 */ 110 function test_converts_alpha_html_entities() { 111 $this->assertEquals("start-agrave-ecirc-ntilde-oslash-aelig-end", sanitize_file_name("start à ê ñ ø æ end" ) ); 112 } 113 114 /** 115 * @ticket 22363 116 */ 117 function test_removes_some_non_alphanum_characters() { 118 $test_input = "start ¿”©“? «±€—°» middle “√¼ = ♫” & „☺ + ☻ = ♥‟ end"; 119 $this->assertEquals("start-¿”©“-«±E—°»-middle-“√¼-♫”-„☺-☻-♥‟-end", sanitize_file_name( $test_input ) ); 120 } 121 122 /** 123 * @ticket 22363 124 */ 125 function test_removes_nonascii_on_invalid_utf8() { 126 $this->assertEquals( 'Invalid-utf8', sanitize_file_name( "Invalid \xff utf8" ) ); 127 } 70 128 }