Skip to content

Commit

Permalink
lexical filter: fix parsing multiple or pattern (fixes #1296)
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Jul 21, 2023
1 parent 4470bb0 commit 7713f92
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Thruk/Utils/Status.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2771,7 +2771,7 @@ sub _lexical_combine {
push @{$prev2->{'-'.$combine}}, $prev1;
push @{$filter}, $prev2;
} else {
push @{$filter}, { '-'.$combine => [$prev2, $prev1]};
return([{ '-'.$combine => [@{$filter}, $prev2, $prev1] }]);
}
return($filter);
}
Expand Down
5 changes: 4 additions & 1 deletion t/108-thruk_utils_status.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use strict;
use Test::More;
use utf8;

plan tests => 47;
plan tests => 49;

BEGIN {
use lib('t');
Expand Down Expand Up @@ -63,6 +63,9 @@ _test_filter('last_check <= "lastyear"', 'Filter: last_check <= '.Thruk::Utils::
_test_filter('(host_groups ~~ "g1" AND host_groups ~~ "g2") OR (host_name = "h1" and display_name ~~ ".*dn.*")',
"Filter: host_groups ~~ g1\nFilter: host_groups ~~ g2\nAnd: 2\nFilter: host_name = h1\nFilter: display_name ~~ .*dn.*\nAnd: 2\nOr: 2",
"(host_groups ~~ 'g1' and host_groups ~~ 'g2') or (host_name = 'h1' and display_name ~~ '.*dn.*')");
_test_filter('(host_name = 1) or (host_name = 2) or (host_name = 3)',
"Filter: host_name = 1\nFilter: host_name = 2\nFilter: host_name = 3\nOr: 3",
"host_name = 1 or host_name = 2 or host_name = 3");

sub _test_filter {
my($filter, $expect, $exp_ftext) = @_;
Expand Down

0 comments on commit 7713f92

Please sign in to comment.