mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
FilterQueryString: fix issues with not
NOT is a "chain" with just one subfilter and therefore behaves a little bit different. Should work fine now. fixes #6554
This commit is contained in:
parent
1dcf44b9cd
commit
9359f527db
@ -122,12 +122,16 @@ class FilterQueryString
|
|||||||
if ($next === '!') {
|
if ($next === '!') {
|
||||||
$not = $this->readFilters($nestingLevel + 1, '!');
|
$not = $this->readFilters($nestingLevel + 1, '!');
|
||||||
$filters[] = $not;
|
$filters[] = $not;
|
||||||
continue;
|
if (in_array($this->nextChar(), array('|', '&', ')'))) {
|
||||||
|
$next = $this->readChar();
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($op === null && count($filters > 0) && ($next === '&' || $next === '|')) {
|
if ($op === null && count($filters > 0) && ($next === '&' || $next === '|')) {
|
||||||
$op = $next;
|
$op = $next;
|
||||||
$next = $this->readChar();
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($next === false) {
|
if ($next === false) {
|
||||||
@ -180,10 +184,15 @@ class FilterQueryString
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($nestingLevel === 0 && count($filters) === 1) {
|
if ($nestingLevel === 0 && $this->pos < $this->length) {
|
||||||
|
$this->parseError($op, 'Did not read full filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($nestingLevel === 0 && count($filters) === 1 && $op !== '!') {
|
||||||
// There is only one filter expression, no chain
|
// There is only one filter expression, no chain
|
||||||
return $filters[0];
|
return $filters[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($op === null && count($filters) === 1) {
|
if ($op === null && count($filters) === 1) {
|
||||||
$op = '&';
|
$op = '&';
|
||||||
}
|
}
|
||||||
@ -204,6 +213,10 @@ class FilterQueryString
|
|||||||
$this->string = $string;
|
$this->string = $string;
|
||||||
|
|
||||||
$this->length = strlen($string);
|
$this->length = strlen($string);
|
||||||
|
|
||||||
|
if ($this->length === 0) {
|
||||||
|
return Filter::matchAll();
|
||||||
|
}
|
||||||
return $this->readFilters();
|
return $this->readFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user