Skip to content
Snippets Groups Projects
Commit a3952f82 authored by Jared Hancock's avatar Jared Hancock
Browse files

files: Avoid crash if `fileinfo` extension missing

parent c18eac40
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