Commit c43ef45d authored by Francois Marier's avatar Francois Marier
Browse files

file_mime_type: increase use of hardcoded magic file (bug #809216)

Mahara's mimetype detection function wasn't working properly and
so it would not be able to set the right mimetype when a browser
(typically IE) sets it to a generic value.

The workaround in 821a693c is not
sufficient because symlinks, like directories, don't work but the
is_file() function will resolve them and may return true.

Change-Id: Ie8485ee10e5142a5f00032116c5492b9778dae51
Signed-off-by: default avatarFrancois Marier <>
parent 98ad55b4
......@@ -326,8 +326,11 @@ function file_mime_type($file) {
// if /usr/share/misc/magic is a directory then finfo still succeeds and
// doesn't fall back onto the .mcg magic_file
// force /usr/share/misc/magic.mgc instead in this case
$magicfile = !is_file('/usr/share/misc/magic') ? '/usr/share/misc/magic.mgc' : null;
$MAGICPATH = '/usr/share/misc/magic';
$magicfile = null;
if (is_dir($MAGICPATH) or is_link($MAGICPATH)) {
$magicfile = '/usr/share/misc/magic.mgc';
if (defined('FILEINFO_MIME_TYPE')) {
if ($finfo = @new finfo(FILEINFO_MIME_TYPE, $magicfile)) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment