From a023fbce186748782d89c6180009fd4df569fda8 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Wed, 30 Aug 2023 22:30:06 +0000 Subject: [PATCH] Upload: Add a MIME type exception for `.docx` generated by Google Docs. This changeset adds an exception to prevent permission issues on `.docx` generated by Google Docs. This is a temporary fix for an upstream bug on the `finfo_file()` PHP function which returns a redundant MIME type for these documents. Props winterstreet, jakariaistauk, mujuonly, mi5t4n, annashopina, audrasjb, azaozz, mikeschroder, oglekler. Fixes #57898. git-svn-id: https://develop.svn.wordpress.org/trunk@56497 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index be03264455..dfe8af4335 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -3150,6 +3150,11 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { $real_mime = finfo_file( $finfo, $file ); finfo_close( $finfo ); + // finfo_file() returns redudant mime type for Google docs, see #57898. + if ( 'application/vnd.openxmlformats-officedocument.wordprocessingml.documentapplication/vnd.openxmlformats-officedocument.wordprocessingml.document' === $real_mime ) { + $real_mime = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; + } + // fileinfo often misidentifies obscure files as one of these types. $nonspecific_types = array( 'application/octet-stream',