[ticket/10963] Modified filespec::is_image() to check actual mimetype

Modified filespec::is_image() to check the Fileinfo mimetype rather than
trusting the browser.

PHPBB3-10963
This commit is contained in:
Fyorl 2012-06-15 14:10:20 +01:00
parent a0771b8814
commit 03ddfbbaf1

View file

@ -151,7 +151,10 @@ class filespec
*/ */
function is_image() function is_image()
{ {
return (strpos($this->mimetype, 'image/') !== false) ? true : false; $finfo = new finfo(FILEINFO_MIME_TYPE);
$mimetype = $finfo->file($this->filename);
return (strpos($mimetype, 'image/') !== false) ? true : false;
} }
/** /**
@ -342,6 +345,7 @@ class filespec
// Remove temporary filename // Remove temporary filename
@unlink($this->filename); @unlink($this->filename);
$this->filename = $this->destination_file;
if (sizeof($this->error)) if (sizeof($this->error))
{ {