[wp-trac] [WordPress Trac] #39951: upload_mimes hook does not work for woff files with media_handle_upload()

WordPress Trac noreply at wordpress.org
Thu Feb 23 15:26:47 UTC 2017


#39951: upload_mimes hook does not work for woff files with media_handle_upload()
----------------------------------+-----------------------------
 Reporter:  kontur                |      Owner:
     Type:  defect (bug)          |     Status:  new
 Priority:  normal                |  Milestone:  Awaiting Review
Component:  Upload                |    Version:  4.7.2
 Severity:  normal                |   Keywords:
  Focuses:  docs, administration  |
----------------------------------+-----------------------------
 I have extended allowed upload mime types as explained
 (https://codex.wordpress.org/Plugin_API/Filter_Reference/upload_mimes).

 Using get_allowed_mime_types() I can confirm those get registered
 correctly.

 However, media_handle_upload() still results in an error: "Sorry, this
 file type is not permitted for security reasons."

 media_handle_upload() calls wp_handle_upload()
 (https://core.trac.wordpress.org/browser/tags/4.7.2/src/wp-
 admin/includes/media.php?rev=40103#L281) and in that function
 wp_check_file_and_ext is called
 (https://core.trac.wordpress.org/browser/tags/4.7.2/src/wp-
 admin/includes/file.php?rev=40103#L342).

 However, reading the documentation for wp_check_filetype_and_ext()
 (https://codex.wordpress.org/Function_Reference/wp_check_filetype_and_ext)
 states:
 Currently this function only supports validating images known to
 getimagesize().

 Maybe this is or is not the reason that the extended mime types have no
 effect. Either way, adding the mime type for woff does not allow those
 uploads, which seems like a clear bug.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39951>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list