From 1f4586ec92f7e7231f9a6f56c43c368bfaa1db12 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sat, 20 Dec 2014 19:18:04 -0600 Subject: [PATCH] Fixing issue 71 --- indefero/src/IDF/FileUtil.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/indefero/src/IDF/FileUtil.php b/indefero/src/IDF/FileUtil.php index 3b2c388..735bd25 100644 --- a/indefero/src/IDF/FileUtil.php +++ b/indefero/src/IDF/FileUtil.php @@ -142,10 +142,24 @@ class IDF_FileUtil */ public static function getMimeTypeFromContent($file, $filedata) { + // There is a bug/memory leak in finfo_buffer + // finfo_buffer works 99% of the time - so rather than + // replacing it with some complex mime check system - just create + // a list of extensions that we know + // And document the types best we can: + // po is a translation file in indefero - tried text/plain but the syntax highlight JS library didn't like it + $ext_hack = array("po" => "application/octet-stream"); $info = pathinfo($file); $res = array('application/octet-stream', $info['basename'], isset($info['extension']) ? $info['extension'] : 'bin'); + + if (array_key_exists($info["extension"], $ext_hack)) + { + $res[0] = $ext_hack[$info["extension"]]; + return $res; + } + if (function_exists('finfo_open')) { $finfo = finfo_open(FILEINFO_MIME); $mime = finfo_buffer($finfo, $filedata);