Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit c1f98af

Browse files
committed
dont allow jar or php file uploads
1 parent c29df2e commit c1f98af

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

src/Controllers/MediaController.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class MediaController extends Controller
1616
private $fileChars;
1717
private $folderChars;
1818
private $sanitizedText;
19-
private $framework;
19+
private $fw;
2020

2121
public function __construct()
2222
{
@@ -26,7 +26,7 @@ public function __construct()
2626
$this->fileChars = config('mediaManager.allowed_fileNames_chars');
2727
$this->folderChars = config('mediaManager.allowed_folderNames_chars');
2828
$this->sanitizedText = config('mediaManager.sanitized_text');
29-
$this->framework = config('mediaManager.framework');
29+
$this->fw = config('mediaManager.framework');
3030
}
3131

3232
/**
@@ -36,7 +36,7 @@ public function __construct()
3636
*/
3737
public function index()
3838
{
39-
return view("MediaManager::{$this->framework}.media");
39+
return view("MediaManager::{$this->fw}.media");
4040
}
4141

4242
/**
@@ -54,8 +54,14 @@ public function upload(Request $request)
5454
foreach ($request->file as $one) {
5555
$file_name = $one->getClientOriginalName();
5656
$destination = "$upload_path/{$this->cleanName($file_name)}";
57+
$file_type = $one->getMimeType();
5758

5859
try {
60+
// stop if "php" or "jar"
61+
if (strpos($file_type, "php") || strpos($file_type, "jar")) {
62+
throw new Exception(trans('MediaManager::messages.not_allowed_file_ext', ['attr'=>$file_type]));
63+
}
64+
5965
// check existence
6066
if ($this->storageDisk->exists($destination)) {
6167
throw new Exception(trans('MediaManager::messages.error_may_exist'));

src/dist/style.c769d7bc24e95f980d5d13b4d8819bdb.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/resources/assets/sass/shared-styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ $blue_2: #276cda;
5959
justify-content: space-between;
6060
.breadcrumb {
6161
background: none;
62-
margin-bottom: 0;
62+
margin-bottom: 0 !important;
6363
padding: 0;
6464
border-radius: 0;
6565
list-style: none;

src/resources/lang/en/messages.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@
3333
'too_many_files' => 'Too Many Files...',
3434
'url' => 'URL',
3535
'upload' => 'Upload',
36+
'not_allowed_file_ext' => 'Files Of Type ":attr" Are Not Allowed',
3637
];

0 commit comments

Comments
 (0)