Make WordPress Core

Changeset 42525


Ignore:
Timestamp:
01/17/2018 07:15:57 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Media: In _wp_handle_upload(), check if the file was properly uploaded before checking its size.

Props achbed, dglingren.
Fixes #39522.

File:
1 edited

Legend:

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

    r42343 r42525  
    779779    }
    780780
     781    // A properly uploaded file will pass this test. There should be no reason to override this one.
     782    $test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file( $file['tmp_name'] ) : @ is_readable( $file['tmp_name'] );
     783    if ( ! $test_uploaded_file ) {
     784        return call_user_func_array( $upload_error_handler, array( &$file, __( 'Specified file failed upload test.' ) ) );
     785    }
     786
    781787    $test_file_size = 'wp_handle_upload' === $action ? $file['size'] : filesize( $file['tmp_name'] );
    782788    // A non-empty file will pass this test.
     
    788794        }
    789795        return call_user_func_array( $upload_error_handler, array( &$file, $error_msg ) );
    790     }
    791 
    792     // A properly uploaded file will pass this test. There should be no reason to override this one.
    793     $test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file( $file['tmp_name'] ) : @ is_file( $file['tmp_name'] );
    794     if ( ! $test_uploaded_file ) {
    795         return call_user_func_array( $upload_error_handler, array( &$file, __( 'Specified file failed upload test.' ) ) );
    796796    }
    797797
Note: See TracChangeset for help on using the changeset viewer.