Media: Accept audio files stored in an MP4 container detected as video/mp4 - #13156
Media: Accept audio files stored in an MP4 container detected as video/mp4#13156sanketio wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the 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. |
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. |
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