WordPress.org

Make WordPress Core

Changeset 30640


Ignore:
Timestamp:
11/30/2014 06:32:16 AM (5 years ago)
Author:
wonderboymusic
Message:

Adjust the RegEx in wp_check_filetype() to be aware that query strings are thing that exist sometimes in URLs.

Adds unit tests.

Props voldemortensen.
Fixes #30377.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r30614 r30640  
    20502050
    20512051    foreach ( $mimes as $ext_preg => $mime_match ) {
    2052         $ext_preg = '!\.(' . $ext_preg . ')$!i';
     2052        $ext_preg = '!\.(' . $ext_preg . ')(\?.*)?$!i';
    20532053        if ( preg_match( $ext_preg, $filename, $ext_matches ) ) {
    20542054            $type = $mime_match;
  • trunk/tests/phpunit/tests/media.php

    r30501 r30640  
    468468    }
    469469
     470    function test_wp_check_filetype() {
     471        $url = 'http://example.com/testFile.mp4?autoplay=true&otherstuff=false';
     472        $filetype = wp_check_filetype( $url );
     473        $expected = array(
     474            'ext'  => 'mp4',
     475            'type' => 'video/mp4'
     476        );
     477        $this->assertEquals( $expected, $filetype );
     478    }
    470479}
Note: See TracChangeset for help on using the changeset viewer.