mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 16:24:04 +02:00
filter: Fix whitepsace sanitation when expression is an array
This commit is contained in:
parent
56a1af47e7
commit
ebde422824
@ -132,7 +132,7 @@ abstract class Filter
|
|||||||
public static function expression($col, $op, $expression)
|
public static function expression($col, $op, $expression)
|
||||||
{
|
{
|
||||||
$col = trim($col);
|
$col = trim($col);
|
||||||
$expression = trim($expression);
|
$expression = is_array($expression) ? array_map('trim', $expression) : trim($expression);
|
||||||
switch ($op) {
|
switch ($op) {
|
||||||
case '=': return new FilterMatch($col, $op, $expression);
|
case '=': return new FilterMatch($col, $op, $expression);
|
||||||
case '<': return new FilterLessThan($col, $op, $expression);
|
case '<': return new FilterLessThan($col, $op, $expression);
|
||||||
|
@ -204,9 +204,11 @@ class FilterTest extends BaseTestCase
|
|||||||
$columnHasWhitespaces = Filter::where(' host ', 'localhost');
|
$columnHasWhitespaces = Filter::where(' host ', 'localhost');
|
||||||
$expressionHasWhitespaces = Filter::where('host', ' localhost ');
|
$expressionHasWhitespaces = Filter::where('host', ' localhost ');
|
||||||
$bothHaveWhitespaces = Filter::fromQueryString(' host = localhost ');
|
$bothHaveWhitespaces = Filter::fromQueryString(' host = localhost ');
|
||||||
|
$withArray = Filter::where(' host ', array(' no match ', ' localhost '));
|
||||||
$this->assertTrue($columnHasWhitespaces->matches($this->sampleData[0]));
|
$this->assertTrue($columnHasWhitespaces->matches($this->sampleData[0]));
|
||||||
$this->assertTrue($expressionHasWhitespaces->matches($this->sampleData[0]));
|
$this->assertTrue($expressionHasWhitespaces->matches($this->sampleData[0]));
|
||||||
$this->assertTrue($bothHaveWhitespaces->matches($this->sampleData[0]));
|
$this->assertTrue($bothHaveWhitespaces->matches($this->sampleData[0]));
|
||||||
|
$this->assertTrue($withArray->matches($this->sampleData[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function row($idx)
|
private function row($idx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user