Skip to content

Commit

Permalink
Prevent filters to be called on empty values
Browse files Browse the repository at this point in the history
  • Loading branch information
neveldo committed Mar 30, 2017
1 parent ac6e775 commit c6bcec2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/TextGenerator/TextFunction/FilterFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ public function execute(array $arguments, array $originalArguments)
);
}

if ($arguments[0] === $this->tagReplacer->getEmptyTag()) {
return '';
}

if (isset($filter['maxArgs']) && count($arguments) > $filter['maxArgs']) {
throw new \InvalidArgumentException(
sprintf("Filter %s expect maximum %d parameters, %d given.", $filterName, $filter['maxArgs'], (count($arguments)))
Expand Down

0 comments on commit c6bcec2

Please sign in to comment.