From 06426bdfe6604356c08430337532082bbd540f81 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 22 Sep 2012 23:15:25 +0100 Subject: [PATCH] when checking mime types, use the filename.ext from the DB, not the (non-existent) .ext on disk --- core/imageboard.pack.php | 2 +- core/util.inc.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index 02f5f221..a11c1620 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -387,7 +387,7 @@ class Image { * @retval string */ public function get_mime_type() { - return getMimeType($this->get_image_filename()); + return getMimeType($this->get_image_filename(), $this->get_ext()); } /** diff --git a/core/util.inc.php b/core/util.inc.php index b1670b7e..a18b1923 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -489,7 +489,7 @@ function captcha_check() { * @param string &$file File path * @return string */ -function getMimeType($file) { +function getMimeType($file, $ext="") { $type = false; // Fileinfo documentation says fileinfo_open() will use the // MAGIC env var for the magic file @@ -527,7 +527,6 @@ function getMimeType($file) { 'avi' => 'video/x-msvideo', 'mpg' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mov' => 'video/quicktime', 'flv' => 'video/x-flv', 'php' => 'text/x-php' ); - $ext = strtolower(pathInfo($file, PATHINFO_EXTENSION)); return isset($exts[$ext]) ? $exts[$ext] : 'application/octet-stream'; }