[wp-trac] [WordPress Trac] #32746: Media Upload mimeType validation bug

WordPress Trac noreply at wordpress.org
Mon Jul 6 15:32:50 UTC 2015


#32746: Media Upload mimeType validation bug
--------------------------+-----------------------------
 Reporter:  vivekbhusal   |       Owner:  wonderboymusic
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  4.3
Component:  Media         |     Version:  4.2.2
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  javascript
--------------------------+-----------------------------

Comment (by wonderboymusic):

 @vivekbhusal some thoughts:

 * [attachment:32746.diff 32746.diff] are the changes I think we should
 make. If you're running the SVN repo, you can run `grunt precommit` before
 making your patch and it will alert you to JS coding style changes that
 need to made
 * I think calling `.toJSON()` is fine - internally, in Backbone, it is
 just a getter for `model.attributes`, which is more forward-compatible
 that directly accessing the property
 * The abbreviated mime is supported - `type` is just the first segment of
 the mime-type. If your library declares `type` as an abbreviated version,
 it will match. The difference we made in [32915] is that the exact mime-
 type will also match. The `type` for these MS docs is actually
 `application`, which could match several false-positives. I believe the
 problem before was this: we were trying to match full mime-types against
 `type`, which would never return `true`. Also, because `indexOf()` is
 polymorphic (works on arrays and strings), and we weren't checking the
 type of `type`, we were getting inconsistent results.

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


More information about the wp-trac mailing list