diff --git a/README.md b/README.md index ffc93456..45d454f3 100644 Binary files a/README.md and b/README.md differ diff --git a/includes/shared.php b/includes/shared.php index b39e0115..6c5fb144 100644 --- a/includes/shared.php +++ b/includes/shared.php @@ -4,7 +4,7 @@ define('AOWOW_REVISION', 19); define('CLI', PHP_SAPI === 'cli'); -$reqExt = ['SimpleXML', 'gd', 'mysqli', 'mbstring']; +$reqExt = ['SimpleXML', 'gd', 'mysqli', 'mbstring', 'fileinfo']; $error = ''; foreach ($reqExt as $r) if (!extension_loaded($r)) diff --git a/pages/screenshot.php b/pages/screenshot.php index e4c68ec2..4b5fbe77 100644 --- a/pages/screenshot.php +++ b/pages/screenshot.php @@ -299,23 +299,19 @@ class ScreenshotPage extends GenericPage return Lang::main('intError'); } + // check if file is an image; allow jpeg, png + $finfo = new finfo(FILEINFO_MIME); // fileInfo appends charset information and other nonsense + $mime = $finfo->file($_FILES['screenshotfile']['tmp_name']); + if (preg_match('/^image\/(png|jpe?g)/i', $mime, $m)) + $isPNG = $m[0] == 'image/png'; + else + return Lang::screenshot('error', 'unkFormat'); + // invalid file $is = getimagesize($_FILES['screenshotfile']['tmp_name']); - if (!$is || empty($is['mime'])) + if (!$is) return Lang::screenshot('error', 'selectSS'); - // allow jpeg, png - switch ($is['mime']) - { - case 'image/png': - $isPNG = true; - case 'image/jpg': - case 'image/jpeg': - break; - default: - return Lang::screenshot('error', 'unkFormat'); - } - // size-missmatch: 4k UHD upper limit; 150px lower limit if ($is[0] < $this->minSize || $is[1] < $this->minSize) return Lang::screenshot('error', 'tooSmall');