Commit 68d77093f1 for wordpress.org
commit 68d77093f14544314f3ef3837746e1327f3465b0
Author: joedolson <joedolson@git.wordpress.org>
Date: Sun Nov 8 19:38:57 2026 +0000
Media: Support specific media types that map to video but contain audio.
Some audio files can legitimately have real mime types that map to video. This causes an upload failure because of the mismatched subtype to primary type.
Add support for .m4a extensions that are detected as video mime types. Subtypes were already allowed in `wp_check_filetype_and_ext()`, but the mismatched major type caused an upload failure.
Developed in https://github.com/WordPress/wordpress-develop/pull/13156.
Props soleo, subrataemfluence, ironprogrammer, joedolson, sanketparmar, arkaprabhachowdhury, andrewssanya, robertbpugh.
Fixes #46544.
Built from https://develop.svn.wordpress.org/trunk@65340
git-svn-id: http://core.svn.wordpress.org/trunk@64480 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index f31c53aa7d..2f5f56d8bd 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -3306,8 +3306,24 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
* and some media files are commonly named with the wrong extension (.mov instead of .mp4)
*/
if ( substr( $real_mime, 0, strcspn( $real_mime, '/' ) ) !== substr( $type, 0, strcspn( $type, '/' ) ) ) {
- $type = false;
- $ext = false;
+ /*
+ * Audio stored in an MP4/ISO-BMFF container (such as .m4a and .m4b, and
+ * some .mp3 files produced by mobile recorders) is frequently detected as
+ * video/mp4. Allow these known audio-in-video-container confusions rather
+ * than rejecting a legitimate audio file whose major types don't match.
+ * Also allow `video/3gpp`, as a RFC 3839 specification-compliant container
+ * for audio-only content.
+ */
+ $cross_container_types = array(
+ 'audio/mpeg' => array( 'video/mp4', 'video/3gpp' ),
+ );
+
+ if ( empty( $cross_container_types[ $type ] )
+ || ! in_array( $real_mime, $cross_container_types[ $type ], true )
+ ) {
+ $type = false;
+ $ext = false;
+ }
}
} elseif ( 'text/plain' === $real_mime ) {
// A few common file types are occasionally detected as text/plain; allow those.
diff --git a/wp-includes/version.php b/wp-includes/version.php
index e5e1130142..fe301f534d 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-beta4-65339';
+$wp_version = '7.2-beta4-65340';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.