Skip to content

Commit

Permalink
[3.4] More php file validation (#8992)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga authored Nov 14, 2023
1 parent 14561f3 commit da28afd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Http/Controllers/CP/Assets/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function store(Request $request)
'container' => 'required',
'folder' => 'required',
'file' => ['file', function ($attribute, $value, $fail) {
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'phtml'])) {
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phar'])) {
$fail(__('validation.uploaded'));
}
}],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function upload(Request $request)
{
$request->validate([
'file' => ['file', function ($attribute, $value, $fail) {
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'phtml'])) {
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phar'])) {
$fail(__('validation.uploaded'));
}
}],
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected function extraRules($fields)
})
->mapWithKeys(function ($field) {
return [$field->handle().'.*' => ['file', function ($attribute, $value, $fail) {
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'phtml'])) {
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phar'])) {
$fail(__('validation.uploaded'));
}
}]];
Expand Down

0 comments on commit da28afd

Please sign in to comment.