Skip to content

Commit 436b5ab

Browse files
committed
Security bug fix.
1 parent a056bab commit 436b5ab

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

app/Controllers/FileManagerController.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
class FileManagerController extends Controller{
1111

1212

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

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

6266
foreach($this->request->up_file as $file){
63-
$images[] = $file->store(str_replace("storage/", "", $this->request->input('dir_path')));
67+
68+
if(!preg_match($this->validationRegex(), strtolower($file))){
69+
$images[] = $file->store(str_replace("storage/", "", $this->request->input('dir_path')));
70+
}
6471
}
6572

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

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

226-
if(\Storage::move($this->request->input('old_file'), $this->request->input('new_file'))){
233+
$new_file = $this->request->input('new_file');
234+
235+
if(!preg_match($this->validationRegex(), strtolower($new_file)) && \Storage::move($this->request->input('old_file'), $new_file)){
227236
if($this->request->ajax()){
228237
return response()->json(['success' => trans('File successfully renamed!')]);
229238
}

0 commit comments

Comments
 (0)