Skip to content

Commit

Permalink
Fixed download attack
Browse files Browse the repository at this point in the history
  • Loading branch information
mafftor committed Jun 5, 2020
1 parent fe3d51d commit ca56205
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Controllers/DownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@

namespace Mafftor\LaravelFileManager\Controllers;

use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Log;

class DownloadController extends LfmController
{
public function getDownload()
{
return response()->download($this->lfm->setName(request('file'))->path('absolute'));
$filepath = $this->helper->getCategoryName() . request('working_dir') . '/' . request('file');

try {
if (Storage::disk($this->helper->config('disk'))->exists($filepath)) {
return response()->download($this->lfm->setName(request('file'))->path('absolute'));
}
} catch (\Exception $e) {
// Do not need to throw the exception
}

Log::error('[laravel-file-manager] File not found - ' . $filepath);
abort(404);
}
}

0 comments on commit ca56205

Please sign in to comment.