Ticket #30377: 30377.4.diff
File 30377.4.diff, 2.5 KB (added by , 8 years ago) |
---|
-
src/wp-includes/canonical.php
567 567 if ( ! empty( $parsed_url['port'] ) ) { 568 568 $url .= ':' . $parsed_url['port']; 569 569 } 570 $url .= $parsed_url['path']; 570 if ( ! empty( $parsed_url['path'] ) ) { 571 $url .= $parsed_url['path']; 572 } 571 573 if ( ! empty( $parsed_url['query'] ) ) { 572 574 $url .= '?' . $parsed_url['query']; 573 575 } -
src/wp-includes/functions.php
2235 2235 $type = false; 2236 2236 $ext = false; 2237 2237 2238 // Strip query args and fragment from filename to reveal extension. 2239 $query_pos = strpos( $filename, '?' ); 2240 2241 if ( false !== $query_pos ) { 2242 $filename = substr_replace( $filename, '', $query_pos ); 2243 } 2244 2245 $filename = strip_fragment_from_url( $filename ); 2246 2238 2247 foreach ( $mimes as $ext_preg => $mime_match ) { 2239 2248 $ext_preg = '!\.(' . $ext_preg . ')$!i'; 2240 2249 if ( preg_match( $ext_preg, $filename, $ext_matches ) ) { -
tests/phpunit/tests/functions/wpCheckFiletype.php
1 <?php 2 3 /** 4 * Tests for wp_check_filetype() 5 * 6 * @group functions.php 7 */ 8 class Tests_Functions_WP_Check_Filetype extends WP_UnitTestCase { 9 10 public function _data_url_filetypes() { 11 return array( 12 array( null, false ), 13 array( '', false ), 14 array( ' ', false ), 15 array( 'http://example.com', false ), 16 array( 'http://example.com/', false ), 17 array( 'http://example.com/wibble', false ), 18 array( 'http://example.com/wibble/', false ), 19 array( 'http://example.com/wibble.wobble', false ), 20 array( 'http://example.com/wibble.mp3', 'mp3' ), 21 array( 'http://example.com/wibble.mp3#wobble', 'mp3' ), 22 array( 'http://example.com/wibble.mp3?wobble=true', 'mp3' ), 23 array( 'http://example.com/wibble.mp3?wobble=true#wobble', 'mp3' ), 24 ); 25 } 26 27 /** 28 * @dataProvider _data_url_filetypes 29 * 30 * @param $url 31 * @param $expected 32 */ 33 public function test_url_ext( $url, $expected ) { 34 $filetype = wp_check_filetype( $url ); 35 $this->assertSame( $expected, $filetype['ext'] ); 36 } 37 }