Skip to content

Commit da28afd

Browse files
authored
[3.4] More php file validation (#8992)
1 parent 14561f3 commit da28afd

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
@@ -165,7 +165,7 @@ protected function extraRules($fields)
165165
})
166166
->mapWithKeys(function ($field) {
167167
return [$field->handle().'.*' => ['file', function ($attribute, $value, $fail) {
168-
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'phtml'])) {
168+
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phar'])) {
169169
$fail(__('validation.uploaded'));
170170
}
171171
}]];

0 commit comments

Comments
 (0)