From d74272ecf597125140d4357ebcdaac2a13938d29 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 15 May 2014 04:31:14 +0000 Subject: [PATCH] Eliminate one of the uses of `extract()` in `wp_handle_upload()`. See #22400. Built from https://develop.svn.wordpress.org/trunk@28417 git-svn-id: http://core.svn.wordpress.org/trunk@28244 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/file.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index 997b5fe20e..e92cf36423 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -284,18 +284,20 @@ function wp_handle_upload( &$file, $overrides = false, $time = null ) { // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter. if ( $test_type ) { $wp_filetype = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'], $mimes ); - - extract( $wp_filetype ); + $ext = empty( $wp_filetype['ext'] ) ? '' : $wp_filetype['ext']; + $type = empty( $wp_filetype['type'] ) ? '' : $wp_filetype['type']; + $proper_filename = empty( $wp_filetype['proper_filename'] ) ? '' : $wp_filetype['proper_filename']; // Check to see if wp_check_filetype_and_ext() determined the filename was incorrect - if ( $proper_filename ) + if ( $proper_filename ) { $file['name'] = $proper_filename; - - if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) ) - return call_user_func($upload_error_handler, $file, __( 'Sorry, this file type is not permitted for security reasons.' )); - - if ( !$type ) + } + if ( ( ! $type || !$ext ) && ! current_user_can( 'unfiltered_upload' ) ) { + return call_user_func( $upload_error_handler, $file, __( 'Sorry, this file type is not permitted for security reasons.' ) ); + } + if ( ! $type ) { $type = $file['type']; + } } else { $type = ''; }