diff --git a/lib/Thruk/Controller/rest_v1.pm b/lib/Thruk/Controller/rest_v1.pm index df0170fc7..1da872d06 100644 --- a/lib/Thruk/Controller/rest_v1.pm +++ b/lib/Thruk/Controller/rest_v1.pm @@ -2893,7 +2893,7 @@ sub _parse_columns_data { $name = shift @arg; push(@{$functions}, [$f, \@arg]); } - if(scalar @{$functions} == 0 && $name =~ m/[\+\*\-\/]/gmx) { + if(scalar @{$functions} == 0 && $name =~ m/.+[\+\*\-\/].+/gmx && $raw->[$x] !~ m/^`.*`$/mx) { # NO CRITIC BACKTICKS my $f = "_calc"; push(@{$functions}, [$f, [$name]]); } diff --git a/t/092-backticks.t b/t/092-backticks.t index 8cbae0c6d..6baad75a0 100644 --- a/t/092-backticks.t +++ b/t/092-backticks.t @@ -21,6 +21,7 @@ for my $cmd (@{$cmds}) { chomp($line); $line =~ s/'.*?'//gmx; next if $line =~ m/nasty\ chars/mx; + next if $line =~ m/NO\ CRITIC\ BACKTICKS/mx; $line =~ s/\#.*$//gmx; next if($filter && $line !~ m%$filter%mx); next if $line =~ m%\QThruk/Utils/IO.pm:\E%mx; diff --git a/t/scenarios/rest_api/t/local/rest_api_misc.t b/t/scenarios/rest_api/t/local/rest_api_misc.t index 339245815..242ed6ad8 100644 --- a/t/scenarios/rest_api/t/local/rest_api_misc.t +++ b/t/scenarios/rest_api/t/local/rest_api_misc.t @@ -8,7 +8,7 @@ BEGIN { require TestUtils; import TestUtils; } -plan tests => 76; +plan tests => 94; ########################################################### # test thruks script path @@ -114,3 +114,24 @@ $ENV{'THRUK_TEST_AUTH_USER'} = "omdadmin"; } ########################################################### +{ + # make sure / columns do not interfer with calculations + TestUtils::test_command({ + cmd => '/usr/bin/env thruk r \'/services?columns=name,/\'', + like => ['/"\/"\s*:\s*\d+,/'], + }); + TestUtils::test_command({ + cmd => '/usr/bin/env thruk r \'/services?columns=name,`/`\'', + like => ['/"\/"\s*:\s*\d+,/'], + }); + TestUtils::test_command({ + cmd => '/usr/bin/env thruk r \'/services?columns=name,`/`,latency/5\'', + like => ['/"\/"\s*:\s*\d+,/', '/"latency\/5"/'], + }); + TestUtils::test_command({ + cmd => '/usr/bin/env thruk r \'/services?columns=name,/,latency/5\'', + like => ['/"\/"\s*:\s*\d+,/', '/"latency\/5"/'], + }); +} + +###########################################################