[wp-trac] [WordPress Trac] #39963: MIME Alias Handling

WordPress Trac noreply at wordpress.org
Tue Mar 7 22:01:38 UTC 2017


#39963: MIME Alias Handling
-------------------------+------------------------------
 Reporter:  blobfolio    |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Media        |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+------------------------------

Comment (by blobfolio):

 The MIME list has been extended to include more results:
   -- MacOS file types, namely those Apple didn't register with IANA)
   -- parent classes (like `application/ogg`, which some systems return
 instead of specific types like `video/ogg`)

 There's now a third function:
 {{{#!php
 <?php
 /**
  * Retrieve the "real" file type from the file.
  *
  * This extends `wp_check_filetype()` to additionally
  * consider content-based indicators of a file's
  * true type.
  *
  * The content-based type will override the name-based
  * type if available and included in the $mimes list.
  *
  * @since xxx
  *
  * @see wp_check_filetype()
  * @see wp_check_filetype_and_ext()
  *
  * @param string $file Full path to the file.
  * @param string $filename The name of the file (may differ from $file due
 to $file being in a tmp directory).
  * @param array $mimes Optional. Key is the file extension with value as
 the mime type.
  * @return array Values with extension first and mime type.
  */
 function wp_check_real_filetype( $file, $filename = null, $mimes = null )
 { ... }
 }}}

 The idea is to abstract the type-checking from other sanitizing/handling
 being performed in `wp_check_filetype_and_ext()` so that it can be called
 from other functions that might need a more robust type determination.
 `wp_check_filetype_and_ext()` could then be reduced so that it calls this
 function, then handles its specific validation checks.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39963#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list