From b135ee8bbaeaac9658ff6b3c0d1543cccce4a5f4 Mon Sep 17 00:00:00 2001 From: Fabian Franz Date: Mon, 11 Feb 2019 18:07:01 +0100 Subject: [PATCH 1/2] rspamd: fix constraint --- .../Constraints/ComparedToFieldConstraint.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php index ffb0ca41a..35f209e9a 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php @@ -54,17 +54,22 @@ class ComparedToFieldConstraint extends BaseConstraint $node = $this->getOption('node'); $field_name = $this->getOption('field'); $operator = $this->getOption('operator'); - if ($node && !empty($operator) && !empty($field_name)) { + //var_dump($node); + if ($node && !($this->isEmpty($node) || empty($operator) || empty($field_name))) { $parent_node = $node->getParentNode(); $other_node_content = $parent_node->$field_name; - if (!((!$this->isEmpty($node) && !$this->isEmpty($other_node_content)) && // check if all fields are set - is_numeric((string)$node) && is_numeric((string)$other_node_content) && // check if both are numeric - $this->is_contraint_fulfilled( + // if the other field is not set, or invalid type -> ignore this constraint + if ($this->isEmpty($other_node_content) || + !is_numeric((string)$node) && !is_numeric((string)$other_node_content)) { + return true; + } + + if (!$this->is_contraint_fulfilled( $operator, floatval((string)$node), floatval((string)$other_node_content) - ))) { + )){ $this->appendMessage($validator, $attribute); } } From 74f7ae60b10795c1a14aaba9418616be51591b3c Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Wed, 13 Feb 2019 08:51:54 +0100 Subject: [PATCH 2/2] style sweep --- .../OPNsense/Base/Constraints/ComparedToFieldConstraint.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php index 35f209e9a..13c964ba0 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php @@ -54,14 +54,13 @@ class ComparedToFieldConstraint extends BaseConstraint $node = $this->getOption('node'); $field_name = $this->getOption('field'); $operator = $this->getOption('operator'); - //var_dump($node); if ($node && !($this->isEmpty($node) || empty($operator) || empty($field_name))) { $parent_node = $node->getParentNode(); $other_node_content = $parent_node->$field_name; // if the other field is not set, or invalid type -> ignore this constraint if ($this->isEmpty($other_node_content) || - !is_numeric((string)$node) && !is_numeric((string)$other_node_content)) { + !is_numeric((string)$node) && !is_numeric((string)$other_node_content)) { return true; } @@ -69,7 +68,7 @@ class ComparedToFieldConstraint extends BaseConstraint $operator, floatval((string)$node), floatval((string)$other_node_content) - )){ + )){ $this->appendMessage($validator, $attribute); } }