From 8b3bd573035ebd011e8534fa7d1b264e647ebf9d Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Thu, 9 Nov 2017 14:37:45 -0600 Subject: [PATCH] fix: Number comparisons in alerts and device groups (#7695) Remove quotes so if the field we are comparing against is a string type, we still do a number comparison. --- html/includes/modal/new_alert_rule.inc.php | 2 +- html/includes/modal/new_device_group.inc.php | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/html/includes/modal/new_alert_rule.inc.php b/html/includes/modal/new_alert_rule.inc.php index 7c014e31cd..2c16bd4bec 100644 --- a/html/includes/modal/new_alert_rule.inc.php +++ b/html/includes/modal/new_alert_rule.inc.php @@ -357,7 +357,7 @@ $('#and').click('', function(e) { strategy: 'array', tagFieldName: 'rules[]' }); - if(value.indexOf("%") < 0) { + if(value.indexOf("%") < 0 && isNaN(value)) { value = '"'+value+'"'; } if(entity.indexOf("%") < 0) { diff --git a/html/includes/modal/new_device_group.inc.php b/html/includes/modal/new_device_group.inc.php index edb1110536..220596f1a3 100644 --- a/html/includes/modal/new_device_group.inc.php +++ b/html/includes/modal/new_device_group.inc.php @@ -181,11 +181,13 @@ $('#and, #or').click('', function(e) { strategy: 'array', tagFieldName: 'patterns[]' }); - if(entity.indexOf("%") >= 0) { - $('#response').data('tagmanager').populate([ entity+' '+condition+' '+value+' '+glue ]); - } else { - $('#response').data('tagmanager').populate([ '%'+entity+' '+condition+' "'+value+'" '+glue ]); + if(value.indexOf("%") < 0 && isNaN(value)) { + value = '"'+value+'"'; } + if(entity.indexOf("%") < 0) { + entity = '%'+entity; + } + $('#response').data('tagmanager').populate([ entity+' '+condition+' '+value+' '+glue ]); } });