From c3ff2a1cc663a466aa703615e4d8509ffe4c3af9 Mon Sep 17 00:00:00 2001 From: Clorith Date: Tue, 15 Feb 2022 17:49:00 +0000 Subject: [PATCH] Filesystem API: Use a temp folder for `Content-Disposition` files. #38231 added support for files fetched remotely to have their filename defined by the host using the `Content-Disposition` header. This would then take priority over the existing temporary file name created with `wp_tempnam()` earlier in the process. The change unintentionally omitted the temporary directory path used during uploads, since the `wp_tempnam()` function would have added it previously, so that files with this header ended up being stored in the WordPress root folder, or wp-admin folder, when triggered by WP_Cron or user interactions respectively. This change makes sure the file path includes the temporary directory location when the header is used. Follow-up to [51939]. Props antonynz, azouamauriac. Fixes #55109. Built from https://develop.svn.wordpress.org/trunk@52734 git-svn-id: http://core.svn.wordpress.org/trunk@52323 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/file.php | 2 ++ wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index 46e9ecc6bb..ddd2be849a 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -1198,6 +1198,8 @@ function download_url( $url, $timeout = 300, $signature_verification = false ) { if ( $tmpfname_disposition && is_string( $tmpfname_disposition ) && ( 0 === validate_file( $tmpfname_disposition ) ) ) { + $tmpfname_disposition = dirname( $tmpfname ) . '/' . $tmpfname_disposition; + if ( rename( $tmpfname, $tmpfname_disposition ) ) { $tmpfname = $tmpfname_disposition; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 085663aae6..e9a37d7dce 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-52733'; +$wp_version = '6.0-alpha-52734'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.