Steps to replicate the issue (include links if applicable):
- Download any sample gov sample file https://filesamples.com/formats/ogv
- Upload file
What happens?:
- File is detected as MIME type: application/ogg
Debug logs from MimeAnalyzer
[Mime] MimeAnalyzer::doGuessMimeType: analyzing head and tail of /tmp/phpbdHndf for magic numbers. [Mime] MimeAnalyzer::doGuessMimeType: magic header in /tmp/phpbdHndf recognized as application/ogg [Mime] MimeAnalyzer::guessMimeType: guessed mime type of /tmp/phpbdHndf: application/ogg [Mime] MimeAnalyzer::improveTypeFromExtension: improved mime type for .ogv: application/ogg
What should have happened instead?:
MIME type should be detected as video/ogg; charset=binary
file -bi test.ogv video/ogg; charset=binary /var/www/wiki$ php -a Interactive shell php > $fileinfo = finfo_open(FILEINFO_MIME); php > $mime_type = finfo_file($fileinfo, 'test.ogv'); php > finfo_close($fileinfo); php > php > var_dump($mime_type); string(25) "video/ogg; charset=binary"
Software version (skip for WMF-hosted wikis like Wikipedia):
REL1_39
Other information (browser name/version, screenshots, etc.):
https://doc.wikimedia.org/mediawiki-core/REL1_39/php/MimeAnalyzer_8php_source.html
doGuessMimeType always returns 'application/ogg' for ogg/ogv file since header starts with OggS,
which results in detectMimeType/finfo_file never used to detect the file type
// Hardcode a few magic number checks...
$headers = [
// Multimedia...
'MThd' => 'audio/midi',
'OggS' => 'application/ogg',But even though if video/ogg was detected, mapping of MIME_TYPE_ALIASES still maps it to application/ogg still
/** @var array Map of variant MIME types to their canonical MIME type */ public const MIME_TYPE_ALIASES = [ 'text/javascript' => 'application/javascript', 'application/x-javascript' => 'application/javascript', 'audio/mpeg' => 'audio/mp3', 'audio/ogg' => 'application/ogg', 'video/ogg' => 'application/ogg',