Conditionally add content-type

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-10-17 00:18:34 +01:00
parent 017884f843
commit c01190fac2

View file

@ -132,15 +132,19 @@ class UserFilesController extends Controller
$file = 'private_uploads/users/'.$log->filename;
if ((request('inline') == 'true') && (StorageHelper::allowSafeInline($file) === false)) {
// Display the file as text is not allowed for security reasons
if (request('inline') == 'true') {
$headers = [
'Content-Disposition' => 'inline',
'Content-Type' => 'text/plain',
];
return Storage::download($file, $log->filename, $headers);
// This is NOT allowed as inline - force it to be displayed as text
if (StorageHelper::allowSafeInline($file) === false) {
array_push($headers, ['Content-Type' => 'text/plain']);
}
return Storage::download($file, $log->filename, $headers);
}
return Storage::download($file);