[wp-trac] [WordPress Trac] #32746: Media Upload mimeType validation bug
WordPress Trac
noreply at wordpress.org
Wed Jun 24 02:22:57 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: needs-patch | Focuses: javascript
--------------------------+-----------------------------
Changes (by vivekbhusal):
* status: closed => reopened
* resolution: fixed =>
Comment:
Replying to [comment:5 wonderboymusic]:
> In [changeset:"32916"]:
> {{{
> #!CommitTicketReference repository="" revision="32916"
> Because programming is fun. After [32915], `_.find()` will return
`undefined` if an empty array is passed - in that case, the function
should return `true`.
>
> See #32746.
> }}}
Agree with your patch but there are some fundamental issues.
First thing, we don't need to convert attachment to JSON everytime, its
just added overhead,
Second if we are gonna compare our new file type to provided mime type and
also it should support abbreviated file type, we don't require mimetype of
file.
Third, if above everything the type doesn't exist you have nothing to
worry about and can return at the beginning.
Its just added minor condition check, whether the type is array or not.
The fundamental logic would be still same. This will work better
{{{
type: function( attachment ) {
if( ! this.props.get("type") ) {
return true;
}
var type = this.props.get('type'),
attachmentType = attachment.get("type"), found;
if ( _.isArray( type ) ) {
found = _.find( type, function (t) {
return -1 !== t.indexOf( attachmentType );
} );
} else {
found = -1 !== type.indexOf( attachmentType );
}
return found;
},
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32746#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list