[wp-trac] [WordPress Trac] #30377: wp_check_filetype is broken when checking urls with parameters
WordPress Trac
noreply at wordpress.org
Tue Nov 18 05:05:05 UTC 2014
#30377: wp_check_filetype is broken when checking urls with parameters
-------------------------------------------------+-------------------------
Reporter: supercleanse | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
Component: General | Review
Severity: normal | Version: 4.0
Focuses: ui, javascript, administration, | Keywords:
performance |
-------------------------------------------------+-------------------------
The function in ./wp-includes/media.php named wp_check_filetype has a bug.
It works properly when checking a url such as
http://example.org/coolfile.mp4 but as soon as you add parameters to it (a
common practice when attempting to embed un-cached or amazon pre-signed
urls) like so: http://example.org/coolfile.mp4?extra=true¶ms=true ...
it fails to return the extension / content type.
The fix for this should be *very* easy. The preg_match in this function
that looks like this currently:
{{{
$ext_preg = '!\.(' . $ext_preg . ')$!i';
}}}
could be adjusted to ignore the query string (if there is one) and just
return the true extension like so:
{{{
$ext_preg = '!\.(' . $ext_preg . ')(\?.*)?$!i';
}}}
I've tested this change in my local environment and it works great.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30377>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list