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

Fix incorrect file attachment if filetype is rejected

If an attachment is submitted via the API and the filetype is rejected, the
file would be attached anyway. However, if the file was encoded base64, the
content would not be decoded.
parent 3e871610
No related branches found
No related tags found
No related merge requests found
......@@ -42,7 +42,7 @@ class TicketApiController extends ApiController {
if($data['attachments'] && is_array($data['attachments'])) {
foreach($data['attachments'] as &$attachment) {
if(!$ost->isFileTypeAllowed($attachment))
$data['error'] = 'Invalid file type (ext) for '.Format::htmlchars($attachment['name']);
$attachment['error'] = 'Invalid file type (ext) for '.Format::htmlchars($attachment['name']);
elseif ($attachment['encoding'] && !strcasecmp($attachment['encoding'], 'base64')) {
if(!($attachment['data'] = base64_decode($attachment['data'], true)))
$attachment['error'] = sprintf('%s: Poorly encoded base64 data', Format::htmlchars($attachment['name']));
......
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