From bb4ea7ae3fd7cf8445936fec1b0b7dd65c772400 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 15 May 2014 06:21:51 +0000 Subject: [PATCH] Eliminate the use of `extract()` in `wp_check_filetype_and_ext()`. See #22400. git-svn-id: https://develop.svn.wordpress.org/trunk@28426 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 0390eac793..f98a3f8b5f 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -1987,11 +1987,13 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { // Do basic extension validation and MIME mapping $wp_filetype = wp_check_filetype( $filename, $mimes ); - extract( $wp_filetype ); + $ext = $wp_filetype['ext']; + $type = $wp_filetype['type']; // We can't do any further validation without a file to work with - if ( ! file_exists( $file ) ) + if ( ! file_exists( $file ) ) { return compact( 'ext', 'type', 'proper_filename' ); + } // We're able to validate images using GD if ( $type && 0 === strpos( $type, 'image/' ) && function_exists('getimagesize') ) { @@ -2023,12 +2025,13 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { $filename_parts[] = $mime_to_ext[ $imgstats['mime'] ]; $new_filename = implode( '.', $filename_parts ); - if ( $new_filename != $filename ) + if ( $new_filename != $filename ) { $proper_filename = $new_filename; // Mark that it changed - + } // Redefine the extension / MIME $wp_filetype = wp_check_filetype( $new_filename, $mimes ); - extract( $wp_filetype ); + $ext = $wp_filetype['ext']; + $type = $wp_filetype['type']; } } }