[wp-trac] [WordPress Trac] #39550: Some Non-image files fail to upload after 4.7.1
WordPress Trac
noreply at wordpress.org
Sun Jan 15 23:31:15 UTC 2017
#39550: Some Non-image files fail to upload after 4.7.1
---------------------------+------------------------
Reporter: greatislander | Owner: joemcgill
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 4.7.2
Component: Upload | Version: trunk
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
---------------------------+------------------------
Comment (by blobfolio):
I put together a MIME/extension helper library for PHP:
https://github.com/Blobfolio/blob-mimes
It pulls together MIME/extension sources from IANA, Apache, Nginx, and
freedesktop.org. If running inside a WP install, it also merges the
entries returned by `wp_get_mime_types()`. This provides about 14x the
data WP currently handles.
Maybe something like this should be integrated to provide more robust file
type validation handling? I don't think the behaviors in the main
WordPress MIME/type functions should change (at least not without a flag
or filter to preserve backward compatibility), but the validation
performed in `wp_check_filetype_and_ext()` could be improved to better
work with the range of content users might upload.
The \blobmimes\file() helper provides "magic" `finfo` analysis and
suggested alternative file names when there is a mismatch. Seems like non-
image files should be renamed as well to give their "true" type a chance
to pass the `upload_mimes` test.
Example file info: https://github.com/Blobfolio/blob-
mimes/blob/master/docs/FILE.md#example
Example MIME types by extension: https://github.com/Blobfolio/blob-
mimes/blob/master/docs/EXTENSION.md#example
The \blobmimes\extension()->has_mime() method also provides soft matching
of "x-" type variants, which should help catch some additional outliers.
Any thoughts or suggestions welcome!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39550#comment:52>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list