$type =
$wp_filetype['type'
];
} else { // Reset $real_mime and try validating again.
$real_mime = false;
} } } // Validate files that didn't get validated during previous checks.
if ( $type && !
$real_mime &&
extension_loaded( 'fileinfo'
) ) { $finfo =
finfo_open( FILEINFO_MIME_TYPE
);
$real_mime =
finfo_file( $finfo,
$file );
finfo_close( $finfo );
// fileinfo often misidentifies obscure files as one of these types.
$nonspecific_types = array
( 'application/octet-stream',
'application/encrypted',
'application/CDFV2-encrypted',
'application/zip',
);
/*
* If $real_mime doesn't match the content type we're expecting from the file's extension,
* we need to do some additional vetting. Media types and those listed in $nonspecific_types are
* allowed some leeway, but anything else must exactly match the real content type.
*/