public static function check_alias($ext='', $mime='') {
		// Standardize inputs.
		$mime = strtolower(sanitize_mime_type($mime));
		$ext = trim(strtolower($ext));
		$ext = ltrim($ext, '.');

		// Can't continue if the extension is not in the database.
		if (false === ($mimes = static::get_aliases($ext))) {
			// Filter.
			return apply_filters('blobmimes_check_mime_alias', false, $ext, $mime);
		}

		// Before looking for matches, convert any generic CDFV2
		// types into an equally generic, but less variable type.
		if (0 === strpos($mime, 'application/cdfv2')) {
			$mime = 'application/vnd.ms-office';
		}

		// "Default" MIME might not need to trigger a failure.
		if ('application/octet-stream' === $mime) {
			// Filter.
			if (false === apply_filters('blobmimes_check_application_octet_stream', false)) {
				return apply_filters('blobmimes_check_mime_alias', true, $ext, $mime);
			}
		}
		// An empty file doesn't really have a type.
		elseif ('inode/x-empty' === $mime) {
			return apply_filters('blobmimes_check_mime_alias', true, $ext, $mime);
		}

		// Test for the literal MIME, but also certain generic
		// variations like x-subtype and vnd.subtype.
		$test = array($mime);

		$parts = explode('/', $mime);
		$subtype = count($parts) - 1;
		if ('x-' === substr($parts[$subtype], 0, 2)) {
			$parts[$subtype] = substr($parts[$subtype], 2);
		} else {
			$parts[$subtype] = 'x-' . $parts[$subtype];
		}
		$test[] = implode('/', $parts);

		$parts = explode('/', $mime);
		$subtype = count($parts) - 1;
		if ('vnd.' === substr($parts[$subtype], 0, 4)) {
			$parts[$subtype] = substr($parts[$subtype], 4);
		} else {
			$parts[$subtype] = 'vnd.' . $parts[$subtype];
		}
		$test[] = implode('/', $parts);

		// Overlap is success!
		$found = array_intersect($test, $mimes);
		$match = count($found) > 0;

		// Filter.
		return apply_filters('blobmimes_check_mime_alias', $match, $ext, $mime);
	}
public static function check_alias($ext='', $mime='') {
		// Standardize inputs.
		$mime = strtolower(sanitize_mime_type($mime));
		$ext = trim(strtolower($ext));
		$ext = ltrim($ext, '.');

		// Can't continue if the extension is not in the database.
		if (false === ($mimes = static::get_aliases($ext))) {
			// Filter.
			return apply_filters('blobmimes_check_mime_alias', false, $ext, $mime);
		}

		// Before looking for matches, convert any generic CDFV2
		// types into an equally generic, but less variable type.
		if (0 === strpos($mime, 'application/cdfv2')) {
			$mime = 'application/vnd.ms-office';
		}

		// "Default" MIME might not need to trigger a failure.
		if ('application/octet-stream' === $mime) {
			// Filter.
			if (false === apply_filters('blobmimes_check_application_octet_stream', false)) {
				return apply_filters('blobmimes_check_mime_alias', true, $ext, $mime);
			}
		}
		// An empty file doesn't really have a type.
		elseif ('inode/x-empty' === $mime) {
			return apply_filters('blobmimes_check_mime_alias', true, $ext, $mime);
		}

		// Test for the literal MIME, but also certain generic
		// variations like x-subtype and vnd.subtype.
		$test = array($mime);

		$parts = explode('/', $mime);
		$subtype = count($parts) - 1;
		if ('x-' === substr($parts[$subtype], 0, 2)) {
			$parts[$subtype] = substr($parts[$subtype], 2);
		} else {
			$parts[$subtype] = 'x-' . $parts[$subtype];
		}
		$test[] = implode('/', $parts);

		$parts = explode('/', $mime);
		$subtype = count($parts) - 1;
		if ('vnd.' === substr($parts[$subtype], 0, 4)) {
			$parts[$subtype] = substr($parts[$subtype], 4);
		} else {
			$parts[$subtype] = 'vnd.' . $parts[$subtype];
		}
		$test[] = implode('/', $parts);

		// Overlap is success!
		$found = array_intersect($test, $mimes);
		$match = count($found) > 0;

		// Filter.
		return apply_filters('blobmimes_check_mime_alias', $match, $ext, $mime);
	}
public static function check_alias ( $ ext = '' , $ mime = '' ) { // Standardize inputs. $ mime = strtolower ( sanitize_mime_type ( $ mime ) ) ; $ ext = trim ( strtolower ( $ ext ) ) ; $ ext = ltrim ( $ ext , '.' ) ; // Can't continue if the extension is not in the database. if ( false === ( $ mimes = static :: get_aliases ( $ ext ) ) ) { // Filter. return apply_filters ( 'blobmimes_check_mime_alias' , false , $ ext , $ mime ) ; } // Before looking for matches, convert any generic CDFV2 // types into an equally generic, but less variable type. if ( 0 === strpos ( $ mime , 'application/cdfv2' ) ) { $ mime = 'application/vnd.ms-office' ; } // "Default" MIME might not need to trigger a failure. if ( 'application/octet-stream' === $ mime ) { // Filter. if ( false === apply_filters ( 'blobmimes_check_application_octet_stream' , false ) ) { return apply_filters ( 'blobmimes_check_mime_alias' , true , $ ext , $ mime ) ; } } // An empty file doesn't really have a type. elseif ( 'inode/x-empty' === $ mime ) { return apply_filters ( 'blobmimes_check_mime_alias' , true , $ ext , $ mime ) ; } // Test for the literal MIME, but also certain generic // variations like x-subtype and vnd.subtype. $ test = array ( $ mime ) ; $ parts = explode ( '/' , $ mime ) ; $ subtype = count ( $ parts ) - 1 ; if ( 'x-' === substr ( $ parts [ $ subtype ] , 0 , 2 ) ) { $ parts [ $ subtype ] = substr ( $ parts [ $ subtype ] , 2 ) ; } else { $ parts [ $ subtype ] = 'x-' . $ parts [ $ subtype ] ; } $ test [ ] = implode ( '/' , $ parts ) ; $ parts = explode ( '/' , $ mime ) ; $ subtype = count ( $ parts ) - 1 ; if ( 'vnd.' === substr ( $ parts [ $ subtype ] , 0 , 4 ) ) { $ parts [ $ subtype ] = substr ( $ parts [ $ subtype ] , 4 ) ; } else { $ parts [ $ subtype ] = 'vnd.' . $ parts [ $ subtype ] ; } $ test [ ] = implode ( '/' , $ parts ) ; // Overlap is success! $ found = array_intersect ( $ test , $ mimes ) ; $ match = count ( $ found ) > 0 ; // Filter. return apply_filters ( 'blobmimes_check_mime_alias' , $ match , $ ext , $ mime ) ; }
Check extension and MIME pairing.

@see { https://github.com/php/php-src/blob/3ef069d26c7863b059325b9a0d26cac31c97fe4b/ext/fileinfo/libmagic/readcdf.c }

@param string $ext File extension.
@param string $mime MIME type.
@return bool True/false.
Check extension and MIME pairing .