WordPress.org

Make WordPress Core

Ticket #20074: 20074.4.diff

File 20074.4.diff, 755 bytes (added by dd32, 7 years ago)
  • src/wp-admin/includes/file.php

     
    485485                return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
    486486        }
    487487
     488        $content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
     489        if ( $content_md5 ) {
     490                $md5_file = md5_file( $tmpfname );
     491                if ( $md5_file != $content_md5 ) {
     492                        unlink( $tmpfname );
     493                        return new WP_Error( 'download_verification_failed', sprintf( __( 'The checksum of the download (%1$s) does not match the provided checksum value (%2$s).' ), $md5_file, $content_md5 ) );
     494                }
     495        }
     496
    488497        return $tmpfname;
    489498}
    490499