Skip to content
Snippets Groups Projects
Commit 55de7378 authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #1437 from greezybacon/issue/1427


files: Avoid crash if `file info` extension missing

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 7d7371f4 a3952f82
No related branches found
No related tags found
No related merge requests found
......@@ -331,7 +331,7 @@ class AttachmentFile {
return false;
}
if (!$file['type']) {
if (!$file['type'] && extension_loaded('fileinfo')) {
$finfo = new finfo(FILEINFO_MIME_TYPE);
if ($file['data'])
$type = $finfo->buffer($file['data']);
......@@ -340,9 +340,9 @@ class AttachmentFile {
if ($type)
$file['type'] = $type;
else
$file['type'] = 'application/octet-stream';
}
if (!$file['type'])
$file['type'] = 'application/octet-stream';
$sql='INSERT INTO '.FILE_TABLE.' SET created=NOW() '
.',type='.db_input(strtolower($file['type']))
......
......@@ -33,6 +33,10 @@ $extensions = array(
'name' => 'phar',
'desc' => __('Highly recommended for plugins and language packs')
),
'fileinfo' => array(
'name' => 'fileinfo',
'desc' => __('Used to detect file types for uploads')
),
);
?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment