MediaEdit: handle '*' wildcard in validateMimeType#77168
MediaEdit: handle '*' wildcard in validateMimeType#77168dinhtungdu merged 3 commits intoWordPress:trunkfrom
Conversation
When allowedTypes contains '*', skip MIME type validation entirely.
Previously the wildcard was passed through and matched against
file.type.startsWith('*/') which is never true, causing every upload
to fail with "Sorry, this file type is not supported here."
Fixes WordPress#77149
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
No real-world callers pass '*' through the store-based upload path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@ntsekouras @andrewserong apart from what's fixed in the PR, there is an inconsistency of our handling for button and modal. For button I think we should unify the behavior across all upload paths. And we should be explicit about accepting all types, meaning having only one way (using wildcard) and document it. WDYT? |
I think consistency is a good idea in general, but in this case passing no That's not a strongly held opinion, though! Another thing to keep in mind is that depending on the circumstances it can be advantageous to use the real supported mime types list instead of a wildcard, as was done in some cases last year in #73562 As for this fix, though, this one looks good to get in to me, thanks for handling it! Edit: forgot to mention, keep in mind that if an absence of a value means it's implicitly treated as a wildcard, then folks will already be depending on this behaviour, so it might be hard to change in terms of backwards compatibility. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@andrewserong I see and agree that we need to support both case. For consumers, should we still promote a prefer way enable all allowed types, right? For me using wild card is quite straight forward and explicit. It's also an existing pattern. I updated the docs in 8f44396. But should we commit it now? |
I'd lean a little toward a comment like Whenever you're happy with it, I'd say you're good to merge! |
|
The case with MediaEdit is, it defaults to |
Ah, I see! I think we had a bug with that in the media upload modal where we'd made it default to Yes, for MediaEdit let's leave it as is, then. Thanks for the back and forth here! (And again for the fix 🎉 ) |
What?
Closes #77149
Handle
'*'wildcard invalidateMimeType(@wordpress/media-utils) — skip MIME validation whenallowedTypescontains'*'.Why?
MediaUploadModalpasses raw['*']touploadMedia().validateMimeTypechecksfile.type.startsWith('*/')— always false — so every upload fails with "Sorry, this file type is not supported here."How?
Early-return in
validateMimeTypewhenallowedTypes.includes('*').Testing Instructions
Testing Instructions for Keyboard
Logic-only change, no UI changes.
Screenshots or screencast
Use of AI Tools
Authored with Claude Code (Anthropic).