Skip to content

Commit 9d911f2

Browse files
committed
close #1 Fixed: Incorrectly Sanitised User Input Hides Offline Payments
1 parent 0c998aa commit 9d911f2

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

Http/Requests/Setting.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public function rules()
2525
{
2626
return [
2727
'name' => 'required|string',
28-
'code' => 'required|string',
2928
];
3029
}
3130
}

Jobs/CreatePaymentMethod.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Abstracts\Job;
66
use App\Utilities\Modules;
7+
use Illuminate\Support\Str;
78

89
class CreatePaymentMethod extends Job
910
{
@@ -28,8 +29,10 @@ public function handle()
2829
{
2930
$methods = json_decode(setting('offline-payments.methods'), true);
3031

32+
$code = 'offline-payments.' . Str::slug($this->request->get('name'), '_') . '.' . (count($methods) + 1);
33+
3134
$payment_method = [
32-
'code' => 'offline-payments.' . $this->request->get('code') . '.' . (count($methods) + 1),
35+
'code' => $code,
3336
'name' => $this->request->get('name'),
3437
'customer' => $this->request->get('customer'),
3538
'order' => $this->request->get('order'),

Jobs/DeletePaymentMethod.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ public function handle()
6262
public function authorize()
6363
{
6464
if ($relationships = $this->getRelationships()) {
65-
$message = trans('messages.warning.deleted', ['name' => $this->request->get('code'), 'text' => implode(', ', $relationships)]);
65+
$methods = json_decode(setting('offline-payments.methods'), true);
66+
$method = $methods[array_search($this->request->get('code'), array_column($methods, 'code'))];
67+
68+
$message = trans('messages.warning.deleted', ['name' => $method['name'], 'text' => implode(', ', $relationships)]);
6669

6770
throw new \Exception($message);
6871
}

Jobs/UpdatePaymentMethod.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function handle()
4040
$method = explode('.', $code);
4141

4242
$payment_method = [
43-
'code' => 'offline-payments.' . $this->request->get('code') . '.' . $method[2],
43+
'code' => $code,
4444
'name' => $this->request->get('name'),
4545
'customer' => $this->request->get('customer'),
4646
'order' => $this->request->get('order'),

Resources/views/edit.blade.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
<div class="row">
2828
{{ Form::textGroup('name', trans('general.name'), 'money-check', ['required' => 'required'], null, 'col-md-12') }}
2929

30-
{{ Form::textGroup('code', trans('offline-payments::general.form.code'), 'code', ['required' => 'required'], null, 'col-md-12') }}
31-
3230
{{ Form::radioGroup('customer', trans('offline-payments::general.form.customer'), 0, trans('general.yes'), trans('general.no'), ['required' => 'required'], 'col-md-12') }}
3331

3432
{{ Form::textGroup('order', trans('offline-payments::general.form.order'), 'sort', [], null, 'col-md-12') }}
@@ -61,7 +59,7 @@
6159
<thead class="thead-light">
6260
<tr class="row table-head-line">
6361
<th class="col-xs-6 col-sm-4 col-md-4 col-lg-3">{{ trans('general.name') }}</th>
64-
<th class="col-sm-4 col-md-4 col-lg-4 hidden-sm">{{ trans('offline-payments::general.form.code') }}</th>
62+
<th class="col-sm-4 col-md-4 col-lg-4 hidden-sm">{{ trans('general.description') }}</th>
6563
<th class="col-lg-2 hidden-lg">{{ trans('offline-payments::general.form.order') }}</th>
6664
<th class="col-xs-6 col-sm-4 col-md-4 col-lg-3 text-center">{{ trans('general.actions') }}</th>
6765
</tr>
@@ -71,7 +69,7 @@
7169
@foreach($methods as $item)
7270
<tr class="row align-items-center border-top-1" id="method-{{ $item->code }}">
7371
<td class="col-xs-6 col-sm-4 col-md-4 col-lg-3">{{ $item->name }}</td>
74-
<td class="col-sm-4 col-md-4 col-lg-4 hidden-sm">{{ $item->code }}</td>
72+
<td class="col-sm-4 col-md-4 col-lg-4 hidden-sm long-texts">{{ ($item->description) ?? trans('general.na') }}</td>
7573
<td class="col-lg-2 hidden-lg">{{ $item->order }}</td>
7674
<td class="col-xs-6 col-sm-4 col-md-4 col-lg-3 text-center">
7775
<div class="dropdown">

0 commit comments

Comments
 (0)