Skip to content

Commit

Permalink
Security bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
ttimot24 committed Oct 23, 2020
1 parent a056bab commit 436b5ab
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/Controllers/FileManagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
class FileManagerController extends Controller{


private function validationRegex(){
return '/^.*\.('.implode('|',["php","php5","php7"]).')$/i';
}


/**
* Display a listing of the resource.
Expand Down Expand Up @@ -60,7 +64,10 @@ public function fileupload(){
if ($this->request->hasFile('up_file')){

foreach($this->request->up_file as $file){
$images[] = $file->store(str_replace("storage/", "", $this->request->input('dir_path')));

if(!preg_match($this->validationRegex(), strtolower($file))){
$images[] = $file->store(str_replace("storage/", "", $this->request->input('dir_path')));
}
}

if($this->request->ajax()){
Expand Down Expand Up @@ -223,7 +230,9 @@ public function rename(){

if($this->request->isMethod('POST')){

if(\Storage::move($this->request->input('old_file'), $this->request->input('new_file'))){
$new_file = $this->request->input('new_file');

if(!preg_match($this->validationRegex(), strtolower($new_file)) && \Storage::move($this->request->input('old_file'), $new_file)){
if($this->request->ajax()){
return response()->json(['success' => trans('File successfully renamed!')]);
}
Expand Down

0 comments on commit 436b5ab

Please sign in to comment.