[wp-trac] [WordPress Trac] #40175: Upload Validation / MIME Handling
WordPress Trac
noreply at wordpress.org
Thu Jan 17 19:21:33 UTC 2019
#40175: Upload Validation / MIME Handling
-------------------------------------------------+-------------------------
Reporter: blobfolio | Owner: joemcgill
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: 5.1
Component: Media | Version: 4.7.3
Severity: major | Resolution:
Keywords: has-unit-tests has-patch needs- | Focuses:
testing early needs-dev-note | administration
-------------------------------------------------+-------------------------
Comment (by joemcgill):
@pento – Thanks for the review.
> I think we need to keep the functionality in `wp_maybe_rename_file()`,
but it probably needs a more descriptive name. 😉
Agreed. I'll bike-shed it a bit.
> Is there a particular reason why the array in `wp_get_file_types()`
isn't keyed the same way as the array in `wp_get_mime_types()`? This would
remove a bunch of duplicate entries. Alternatively, perhaps something like
this structure:
The regex style keying has proven to be less robust than this solution
should be, and adds needless complexity when trying to do key => value
lookups in the array. Additionally, there are not often cases where the
full array of possible MIME types will be identical, so in this case I've
chosen a little extra verbosity for much more clarity and flexibility.
> The `wp_get_mime_types()` array could be generated from
`wp_get_file_types()`. Even if it's deprecated, we'd want to keep it
updated for a while.
I agree that this is possible, but we'd need to decide and document which
type to return as the default for each extension. Perhaps it's the first
item in the array of MIMEs? Either way, we probably need to keep a map of
default extensions to mime types for cases where validation isn't
necessary.
> Logistically, I don't think this can be ready for 5.1: it's going to
take a bit of work to integrate it into Core, and I suspect we're going to
run into all sorts of interesting edge cases when plugins work to convert
to it. I think it could easily be committed early to 5.2, though.
This could be true. I'm still going to push for a committable patch by
5.1-beta-2 and we can make a decision in the next few days. Either way, it
will put this in a better position for 5.2-early.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40175#comment:51>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list