Skip to content

Commit 4c6fe04

Browse files
authored
[4.x] More php file validation (#8991)
1 parent 334ebc1 commit 4c6fe04

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Diff for: src/Http/Controllers/CP/Assets/AssetsController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function store(Request $request)
6969
'container' => 'required',
7070
'folder' => 'required',
7171
'file' => ['file', function ($attribute, $value, $fail) {
72-
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'phtml'])) {
72+
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phar'])) {
7373
$fail(__('validation.uploaded'));
7474
}
7575
}],

Diff for: src/Http/Controllers/CP/Fieldtypes/FilesFieldtypeController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function upload(Request $request)
1212
{
1313
$request->validate([
1414
'file' => ['file', function ($attribute, $value, $fail) {
15-
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'phtml'])) {
15+
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phar'])) {
1616
$fail(__('validation.uploaded'));
1717
}
1818
}],

Diff for: src/Http/Controllers/FormController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ protected function extraRules($fields)
178178
})
179179
->mapWithKeys(function ($field) {
180180
return [$field->handle().'.*' => ['file', function ($attribute, $value, $fail) {
181-
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'phtml'])) {
181+
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phar'])) {
182182
$fail(__('validation.uploaded'));
183183
}
184184
}]];

0 commit comments

Comments
 (0)