* the file mime.types in the includes directory.
*/
define('MM_WELL_KNOWN_MIME_TYPES',<<<END_STRING
-application/ogg ogg ogm
+application/ogg ogg ogm ogv
application/pdf pdf
application/x-javascript js
application/x-shockwave-flash swf
image/x-xcf xcf
text/plain txt
text/html html htm
-video/ogg ogm ogg
+video/ogg ogm ogg ogv
video/mpeg mpg mpeg
END_STRING
);
'xbm',
// Formats we recognize magic numbers for
- 'djvu', 'ogg', 'mid', 'pdf', 'wmf', 'xcf',
+ 'djvu', 'ogg', 'ogv', 'mid', 'pdf', 'wmf', 'xcf',
// XML formats we sure hope we recognize reliably
'svg',
wfRestoreWarnings();
if( !$f ) return "unknown/unknown";
$head = fread( $f, 1024 );
+ fseek( $f, -65558, SEEK_END );
+ $tail = fread( $f, 65558 ); // 65558 = maximum size of a zip EOCDR
fclose( $f );
// Hardcode a few magic number checks...
*/
$xml = new XmlTypeCheck( $file );
if( $xml->wellFormed ) {
- $types = array(
- 'http://www.w3.org/2000/svg:svg' => 'image/svg+xml',
- 'svg' => 'image/svg+xml',
- 'http://www.w3.org/1999/xhtml:html' => 'text/html', // application/xhtml+xml?
- 'html' => 'text/html', // application/xhtml+xml?
- );
- if( isset( $types[$xml->rootElement] ) ) {
- $mime = $types[$xml->rootElement];
- return $mime;
+ global $wgXMLMimeTypes;
+ if( isset( $wgXMLMimeTypes[$xml->rootElement] ) ) {
+ return $wgXMLMimeTypes[$xml->rootElement];
} else {
- /// Fixme -- this would be the place to allow additional XML type checks
return 'application/xml';
}
}
}
}
+ // Check for ZIP (before getimagesize)
+ if ( strpos( $tail, "PK\x05\x06" ) !== false ) {
+ wfDebug( __METHOD__.": ZIP header present at end of $file\n" );
+ return 'application/zip';
+ }
+
wfSuppressWarnings();
$gis = getimagesize( $file );
wfRestoreWarnings();
$mime = $gis['mime'];
wfDebug( __METHOD__.": getimagesize detected $file as $mime\n" );
return $mime;
- } else {
- return false;
}
// Also test DjVu
wfDebug( __METHOD__.": detected $file as image/vnd.djvu\n" );
return 'image/vnd.djvu';
}
+
+ return false;
}
/** Internal mime type detection, please use guessMimeType() for application code instead.