Make WordPress Core

Changeset 52829


Ignore:
Timestamp:
03/07/2022 10:50:12 PM (21 months ago)
Author:
audrasjb
Message:

Media: Allow wp_check_filetype() to support query strings in URLs.

This changeset adjusts the regex in wp_check_filetype() to support query strings in URLs.

Follow-up to [30640], [32172].

Props voldemortensen, johnbillion, layotte, dd32, atomicjack, supercleanse, spencercameron, ianmjones, audrasjb.
Fixes #30377.

Location:
trunk
Files:
1 added
1 edited

Legend:

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

    r52719 r52829  
    29822982 *
    29832983 * @since 2.0.4
    2984  *
    2985  * @param string   $filename File name or path.
     2984 * @since 6.0.0 URLs are now supported.
     2985 *
     2986 * @param string   $filename File name, path, or URL.
    29862987 * @param string[] $mimes    Optional. Array of allowed mime types keyed by their file extension regex.
    29872988 * @return array {
     
    29982999    $type = false;
    29993000    $ext  = false;
     3001
     3002    // Strip query args and fragment from filename to reveal extension.
     3003    $query_pos = strpos( $filename, '?' );
     3004
     3005    if ( false !== $query_pos ) {
     3006        $filename = substr_replace( $filename, '', $query_pos );
     3007    }
     3008
     3009    $filename = strip_fragment_from_url( $filename );
    30003010
    30013011    foreach ( $mimes as $ext_preg => $mime_match ) {
Note: See TracChangeset for help on using the changeset viewer.