Repository navigation
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
robertbpugh
left a comment
There was a problem hiding this comment.
Could this also allow video/3gpp? I tested the detection side with PHP 8.5's fileinfo on a two-second AAC file, saved with different container brands:
- M4A brand: audio/x-m4a, which already passes
- isom and mp42: video/mp4, which this PR fixes
- 3gp4, 3gp5 and 3gp6: video/3gpp, which still fails the major-type check with this change
The iPhone recording behind our WordPress.com report had a 3GP brand, so it would still be rejected. Could you add a 3GP-branded fixture next to audio-in-video-container.m4a as well?
Co-authored-by: Rob Pugh <52668747+robertbpugh@users.noreply.github.com>
|
I've had trouble generating a 3gp fixture that actually fails to upload; @robertbpugh do you have a file that would be a good test? |
|
The attached zip has audio-only-3gp4.m4a: three seconds of AAC audio in an MP4 container with the 3gp4 brand. PHP's finfo reads it as video/3gpp on both 8.2 and 8.5. On trunk (the 7.2-beta4-65334 nightly) it fails with "Sorry, you are not allowed to upload this file type." With this PR it uploads as audio/mpeg. A file named .3gp won't reproduce it, since that extension already maps to video/3gpp. The same audio saved as audio-only.3gp (also in the zip) uploads fine on trunk. To make your own: |
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 #13156. Props soleo, subrataemfluence, ironprogrammer, joedolson, sanketparmar, arkaprabhachowdhury, andrewssanya, robertbpugh. Fixes #46544. git-svn-id: https://develop.svn.wordpress.org/trunk@65340 602fd350-edb4-49c9-b593-d223f7449a82
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 WordPress/wordpress-develop#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
Trac ticket: https://core.trac.wordpress.org/ticket/46544
Problem
Uploading an audio file whose real MIME type doesn't share the same major type as its extension is rejected with "Sorry, you are not allowed to upload this file type." The common real-world case is audio stored in an MP4/ISO-BMFF container —
.m4a/.m4b, and some.mp3files produced by mobile recorders — whichfileinfodetects asvideo/mp4, while the extension maps toaudio/mpeg.In
wp_check_filetype_and_ext(), theaudio/*/video/*branch forgives sub-type mismatches but still requires the major type to match, soaudio/mpeg(from the extension) vsvideo/mp4(fromfinfo) fails and the file is rejected.Change
Add a small, curated allow-list for known audio-in-MP4-container confusions inside that branch, mirroring the existing special-casing for
text/csvandtext/rtf. All three affected extensions (m4a,m4b,mp3) map toaudio/mpeg, so the case collapses to a single entry:The check stays strict for every other combination. The
application/octet-streamvariant from the original report already passes today via the$nonspecific_typesbranch, so this targets only the remainingvideo/mp4case.Security: the worst case is a genuine MP4 video uploaded as
.m4abeing treated asaudio/mpeg— both are allowed media types served as downloads, so no new upload vector is opened.Testing instructions
fileinforeports asvideo/mp4(e.g. an.m4afrom a phone recorder, or any MP4 container renamed to.m4a) via Media → Add New.audio/mpeg).Automated coverage: a new case in the
data_wp_check_filetype_and_extprovider uploads a fixture detected asvideo/mp4and asserts it resolves toext = m4a,type = audio/mpeg. The fullTests_Functionssuite passes on single and multisite.Use of AI Tools