From 1d2153b0c1041463e824b261ea5e77acf60b59fc Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 21 Jan 2019 21:51:29 +0000 Subject: [PATCH] Media: Add a `$real_mime` parameter to the `wp_check_filetype_and_ext` filter. This allows more accurate filtering of the filename and extension given to uploaded files. Props desrosj, Tkama. Fixes #45707. git-svn-id: https://develop.svn.wordpress.org/trunk@44677 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 8ee93b4746..2da51d3e3f 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -2638,15 +2638,17 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { * Filters the "real" file type of the given file. * * @since 3.0.0 + * @since 5.1.0 The $real_mime parameter was added. * - * @param array $wp_check_filetype_and_ext File data array containing 'ext', 'type', and - * 'proper_filename' keys. - * @param string $file Full path to the file. - * @param string $filename The name of the file (may differ from $file due to - * $file being in a tmp directory). - * @param array $mimes Key is the file extension with value as the mime type. + * @param array $wp_check_filetype_and_ext File data array containing 'ext', 'type', and + * 'proper_filename' keys. + * @param string $file Full path to the file. + * @param string $filename The name of the file (may differ from $file due to + * $file being in a tmp directory). + * @param array $mimes Key is the file extension with value as the mime type. + * @param string|bool $real_mime The actual mime type or false if the type cannot be determined. */ - return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes ); + return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes, $real_mime ); } /**