-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from Laravel-Backpack/prevent-mimetypes-tampering
Prevent mimetypes tampering
- Loading branch information
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Backpack\FileManager; | ||
|
||
use Illuminate\Support\Facades\Crypt; | ||
use Illuminate\Support\Facades\Log; | ||
|
||
class BackpackElfinderController extends \Barryvdh\Elfinder\ElfinderController | ||
{ | ||
public function showPopup($input_id) | ||
{ | ||
$mimes = request('mimes'); | ||
|
||
if (! isset($mimes)) { | ||
Log::error('Someone attempted to tamper with mime types in elfinder popup. The attempt was blocked.'); | ||
abort(403, 'Unauthorized action.'); | ||
} | ||
|
||
try { | ||
$mimes = Crypt::decrypt(urldecode(request('mimes'))); | ||
} catch (\Illuminate\Contracts\Encryption\DecryptException $e) { | ||
Log::error('Someone attempted to tamper with mime types in elfinder popup. The attempt was blocked.'); | ||
abort(403, 'Unauthorized action.'); | ||
} | ||
|
||
request()->merge(['mimes' => urlencode(serialize($mimes))]); | ||
if (! empty($mimes)) { | ||
request()->merge(['mimes' => urlencode(serialize($mimes))]); | ||
} else { | ||
request()->merge(['mimes' => '']); | ||
} | ||
|
||
return $this->app['view'] | ||
->make($this->package.'::standalonepopup') | ||
->with($this->getViewVars()) | ||
->with(compact('input_id')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters