From 346794bc57ee1942380a75ea59c03ce7ec4e605a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 26 Sep 2020 01:11:09 +0000 Subject: [PATCH] Upload: Add a check in `wp_check_filetype_and_ext()` to account for CSV files having the `application/csv` MIME type. Previously, the PHP Fileinfo extension used to detect CSV files as `text/plain`. In PHP 8, this has changed, and CSV files are detected as `application/csv`. Follow-up to [44438]. See #50913. Built from https://develop.svn.wordpress.org/trunk@49049 git-svn-id: http://core.svn.wordpress.org/trunk@48811 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 16 ++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 87f3fec895..8df5788119 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -2933,6 +2933,7 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { array( 'text/plain', 'text/csv', + 'application/csv', 'text/richtext', 'text/tsv', 'text/vtt', @@ -2943,6 +2944,21 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { $type = false; $ext = false; } + } elseif ( 'application/csv' === $real_mime ) { + // Special casing for CSV files. + if ( ! in_array( + $type, + array( + 'text/csv', + 'text/plain', + 'application/csv', + ), + true + ) + ) { + $type = false; + $ext = false; + } } elseif ( 'text/rtf' === $real_mime ) { // Special casing for RTF files. if ( ! in_array( diff --git a/wp-includes/version.php b/wp-includes/version.php index 60ebe6a26c..aae203cdae 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-49048'; +$wp_version = '5.6-alpha-49049'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.