Skip to content

Commit

Permalink
Add array type verification before accessing index (#49)
Browse files Browse the repository at this point in the history
Since the $rule may now be array as well as a Closure, the array type must be checked before trying to access indexes.
Also, `applyFilter` calls is corrected to respect it's signature.
This should fix `ErrorException Illegal string offset 'name'` being thrown.

Fixes #48
  • Loading branch information
alariva authored and William committed Nov 27, 2019
1 parent 73675ac commit bc7bc73
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ public function sanitize()

$sanitize = true;
foreach ($rules as $rule) {
if ($rule['name'] === 'filter_if') {
$sanitize = $this->applyFilter($rule['name'], $this->data, $rule['options']);
if (is_array($rule) && $rule['name'] === 'filter_if') {
$sanitize = $this->applyFilter($rule, $this->data);
} else {
$value = $this->applyFilter($rule['name'], $value, $rule['options']);
$value = $this->applyFilter($rule, $value);
}
}

Expand Down

0 comments on commit bc7bc73

Please sign in to comment.