Index: src/wp-admin/includes/file.php
===================================================================
--- src/wp-admin/includes/file.php	(revision 38726)
+++ src/wp-admin/includes/file.php	(working copy)
@@ -512,6 +512,13 @@
 		return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
 	}
 
+	$content_disposition = wp_remote_retrieve_header( $response, 'Content-Disposition' );
+	if( ! empty( $content_disposition ) && preg_match( '/filename="([^ ]+)"/', $content_disposition, $matches ) ) {
+		$new_filename = wp_tempnam( $matches[1] );
+		rename( $tmpfname, $new_filename );
+		$tmpfname = $new_filename;
+	}
+
 	$content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
 	if ( $content_md5 ) {
 		$md5_check = verify_file_md5( $tmpfname, $content_md5 );
