WordPress.org

Make WordPress Core

Ticket #38231: 38231.diff

File 38231.diff, 810 bytes (added by cklosows, 3 years ago)
  • src/wp-admin/includes/file.php

     
    512512                return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
    513513        }
    514514
     515        $content_disposition = wp_remote_retrieve_header( $response, 'Content-Disposition' );
     516        if( ! empty( $content_disposition ) && preg_match( '/filename="([^ ]+)"/', $content_disposition, $matches ) ) {
     517                $new_filename = wp_tempnam( $matches[1] );
     518                rename( $tmpfname, $new_filename );
     519                $tmpfname = $new_filename;
     520        }
     521
    515522        $content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
    516523        if ( $content_md5 ) {
    517524                $md5_check = verify_file_md5( $tmpfname, $content_md5 );