Merge branch 'fabianfrz-rspamd_fix_constraint'

This commit is contained in:
Ad Schellevis 2019-02-13 08:52:10 +01:00
commit 7eb9a4f755

View File

@ -54,17 +54,21 @@ class ComparedToFieldConstraint extends BaseConstraint
$node = $this->getOption('node');
$field_name = $this->getOption('field');
$operator = $this->getOption('operator');
if ($node && !empty($operator) && !empty($field_name)) {
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);
}
}