[wp-trac] [WordPress Trac] #40175: Upload Validation / MIME Handling
WordPress Trac
noreply at wordpress.org
Thu Feb 13 18:22:50 UTC 2020
#40175: Upload Validation / MIME Handling
-------------------------------------------------+-------------------------
Reporter: blobfolio | Owner: (none)
Type: defect (bug) | Status: assigned
Priority: high | Milestone: Future
| Release
Component: Media | Version: 4.7.3
Severity: major | Resolution:
Keywords: has-unit-tests early needs-dev-note | Focuses:
| administration
-------------------------------------------------+-------------------------
Comment (by PerS):
My temporary fix is:
{{{#!php
<?php
add_filter( 'wp_check_filetype_and_ext', function(
$wp_check_filetype_and_ext, $file, $filename, $mimes, $real_mime ) {
if ( ! empty( $wp_check_filetype_and_ext['ext'] ) ) {
return $wp_check_filetype_and_ext;
}
$allowed_mime_types = get_allowed_mime_types();
/**
* HACK: Replace mime type 'application/CDFV2[-*]' with the
correct, if allowed, mime type.
*/
if ( false !== strpos( $real_mime, 'application/CDFV2' ) ) {
$ext = end( explode( '.', basename( $filename ) ) );
if ( isset( $allowed_mime_types, $allowed_mime_types[ $ext
] ) ) {
$wp_check_filetype_and_ext = [
'ext' => $ext,
'type' => $allowed_mime_types[ $ext ],
];
}
}
return $wp_check_filetype_and_ext;
}, 10, 5 );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40175#comment:79>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list