File tree Expand file tree Collapse file tree 8 files changed +80
-1
lines changed Expand file tree Collapse file tree 8 files changed +80
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace UniSharp \LaravelFilemanager \Controllers ;
4
4
5
+ use Illuminate \Support \Str ;
5
6
use Intervention \Image \Facades \Image ;
6
7
use UniSharp \LaravelFilemanager \Events \ImageIsCropping ;
7
8
use UniSharp \LaravelFilemanager \Events \ImageWasCropped ;
@@ -29,6 +30,15 @@ public function getCropimage($overWrite = true)
29
30
{
30
31
$ image_name = request ('img ' );
31
32
$ image_path = $ this ->lfm ->setName ($ image_name )->path ('absolute ' );
33
+
34
+ if (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.driver ' ) === 'local ' ){
35
+ $ disk_root = realpath (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.root ' ));
36
+ $ file_real_path = realpath ($ image_path );
37
+ if (!Str::startsWith ($ file_real_path , $ disk_root )){
38
+ abort (404 );
39
+ }
40
+ }
41
+
32
42
$ crop_path = $ image_path ;
33
43
34
44
if (! $ overWrite ) {
Original file line number Diff line number Diff line change 3
3
namespace UniSharp \LaravelFilemanager \Controllers ;
4
4
5
5
use Illuminate \Support \Facades \Storage ;
6
+ use Illuminate \Support \Str ;
6
7
use UniSharp \LaravelFilemanager \Events \FileIsDeleting ;
7
8
use UniSharp \LaravelFilemanager \Events \FileWasDeleted ;
8
9
use UniSharp \LaravelFilemanager \Events \FolderIsDeleting ;
@@ -36,6 +37,14 @@ public function getDelete()
36
37
abort (404 );
37
38
}
38
39
40
+ if (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.driver ' ) === 'local ' ){
41
+ $ disk_root = realpath (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.root ' ));
42
+ $ file_real_path = realpath ($ file ->path ('absolute ' ));
43
+ if (!Str::startsWith ($ file_real_path , $ disk_root )){
44
+ abort (404 );
45
+ }
46
+ }
47
+
39
48
$ file_to_delete = $ this ->lfm ->pretty ($ name_to_delete );
40
49
$ file_path = $ file_to_delete ->path ('absolute ' );
41
50
Original file line number Diff line number Diff line change 3
3
namespace UniSharp \LaravelFilemanager \Controllers ;
4
4
5
5
use Illuminate \Support \Facades \Storage ;
6
+ use Illuminate \Support \Str ;
6
7
7
8
class DownloadController extends LfmController
8
9
{
@@ -14,6 +15,16 @@ public function getDownload()
14
15
abort (404 );
15
16
}
16
17
17
- return response ()->download ($ file ->path ('absolute ' ));
18
+ $ file_absolute = $ file ->path ('absolute ' );
19
+
20
+ if (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.driver ' ) === 'local ' ){
21
+ $ disk_root = realpath (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.root ' ));
22
+ $ file_real_path = realpath ($ file_absolute );
23
+ if (!Str::startsWith ($ file_real_path , $ disk_root )){
24
+ abort (404 );
25
+ }
26
+ }
27
+
28
+ return response ()->download ($ file_absolute );
18
29
}
19
30
}
Original file line number Diff line number Diff line change 2
2
3
3
namespace UniSharp \LaravelFilemanager \Controllers ;
4
4
5
+ use Illuminate \Support \Str ;
5
6
use UniSharp \LaravelFilemanager \Events \FolderIsCreating ;
6
7
use UniSharp \LaravelFilemanager \Events \FolderWasCreated ;
7
8
@@ -44,6 +45,14 @@ public function getAddfolder()
44
45
45
46
$ new_path = $ this ->lfm ->setName ($ folder_name )->path ('absolute ' );
46
47
48
+ if (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.driver ' ) === 'local ' ){
49
+ $ disk_root = realpath (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.root ' ));
50
+ $ file_real_path = realpath ($ new_path );
51
+ if (!Str::startsWith ($ file_real_path , $ disk_root )){
52
+ abort (404 );
53
+ }
54
+ }
55
+
47
56
event (new FolderIsCreating ($ new_path ));
48
57
49
58
try {
Original file line number Diff line number Diff line change 3
3
namespace UniSharp \LaravelFilemanager \Controllers ;
4
4
5
5
use Illuminate \Support \Facades \Storage ;
6
+ use Illuminate \Support \Str ;
6
7
use UniSharp \LaravelFilemanager \Events \FileIsMoving ;
7
8
use UniSharp \LaravelFilemanager \Events \FileWasMoving ;
8
9
use UniSharp \LaravelFilemanager \Events \FolderIsMoving ;
@@ -73,6 +74,14 @@ public function domove()
73
74
abort (404 );
74
75
}
75
76
77
+ if (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.driver ' ) === 'local ' ){
78
+ $ disk_root = realpath (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.root ' ));
79
+ $ file_real_path = realpath ($ file ->path ('absolute ' ));
80
+ if (!Str::startsWith ($ file_real_path , $ disk_root )){
81
+ abort (404 );
82
+ }
83
+ }
84
+
76
85
$ old_path = $ old_file ->path ();
77
86
78
87
if ($ old_file ->hasThumb ()) {
Original file line number Diff line number Diff line change 3
3
namespace UniSharp \LaravelFilemanager \Controllers ;
4
4
5
5
use Illuminate \Support \Facades \Storage ;
6
+ use Illuminate \Support \Str ;
6
7
7
8
class RedirectController extends LfmController
8
9
{
@@ -14,6 +15,16 @@ public function showFile($file_path)
14
15
abort (404 );
15
16
}
16
17
18
+ if (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.driver ' ) === 'local ' ){
19
+ $ file = $ this ->lfm ->setName ($ file_path );
20
+ $ file_absolute = $ file ->path ('absolute ' );
21
+ $ disk_root = realpath (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.root ' ));
22
+ $ file_real_path = realpath ($ file_absolute );
23
+ if (!Str::startsWith ($ file_real_path , $ disk_root )){
24
+ abort (404 );
25
+ }
26
+ }
27
+
17
28
return response ($ storage ->get ($ file_path ))
18
29
->header ('Content-Type ' , $ storage ->mimeType ($ file_path ));
19
30
}
Original file line number Diff line number Diff line change 3
3
namespace UniSharp \LaravelFilemanager \Controllers ;
4
4
5
5
use Illuminate \Support \Facades \Storage ;
6
+ use Illuminate \Support \Str ;
6
7
use UniSharp \LaravelFilemanager \Events \FolderIsRenaming ;
7
8
use UniSharp \LaravelFilemanager \Events \FolderWasRenamed ;
8
9
use UniSharp \LaravelFilemanager \Events \FileIsRenaming ;
@@ -23,6 +24,16 @@ public function getRename()
23
24
abort (404 );
24
25
}
25
26
27
+ $ file_absolute = $ file ->path ('absolute ' );
28
+
29
+ if (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.driver ' ) === 'local ' ){
30
+ $ disk_root = realpath (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.root ' ));
31
+ $ file_real_path = realpath ($ file_absolute );
32
+ if (!Str::startsWith ($ file_real_path , $ disk_root )){
33
+ abort (404 );
34
+ }
35
+ }
36
+
26
37
$ old_file = $ this ->lfm ->pretty ($ old_name );
27
38
28
39
$ is_directory = $ file ->isDirectory ();
Original file line number Diff line number Diff line change 2
2
3
3
namespace UniSharp \LaravelFilemanager \Controllers ;
4
4
5
+ use Illuminate \Support \Str ;
5
6
use Intervention \Image \Facades \Image ;
6
7
use UniSharp \LaravelFilemanager \Events \ImageIsResizing ;
7
8
use UniSharp \LaravelFilemanager \Even
9477
ts \ImageWasResized ;
@@ -56,6 +57,14 @@ public function performResize()
56
57
{
57
58
$ image_path = $ this ->lfm ->setName (request ('img ' ))->path ('absolute ' );
58
59
60
+ if (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.driver ' ) === 'local ' ){
61
+ $ disk_root = realpath (config ('filesystems.disks. ' .$ this ->helper ->config ('disk ' ).'.root ' ));
62
+ $ file_real_path = realpath ($ image_path );
63
+ if (!Str::startsWith ($ file_real_path , $ disk_root )){
64
+ abort (404 );
65
+ }
66
+ }
67
+
59
68
event (new ImageIsResizing ($ image_path ));
60
69
Image::make ($ image_path )->resize (request ('dataWidth ' ), request ('dataHeight ' ))->save ();
61
70
event (new ImageWasResized ($ image_path ));
You can’t perform that action at this time.
0 commit comments