diff options
author | Andrejs Verza <andrejs.verza@zabbix.com> | 2022-03-07 13:25:32 +0300 |
---|---|---|
committer | Andrejs Verza <andrejs.verza@zabbix.com> | 2022-03-07 13:25:32 +0300 |
commit | a7f6f493b551b88d2dc7c845c975cbb90e942960 (patch) | |
tree | 27adba1fe1322b80f98c3a7cc31b5d1e9bb323ae /ui | |
parent | 187c4d85dd4a4df507301e79785c2d6b338917fb (diff) |
..F....... [ZBX-19583] added uint64 input validation rule
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/controllers/CControllerPopupSlaExcludedDowntimeEdit.php | 4 | ||||
-rw-r--r-- | ui/include/classes/parsers/CValidationRule.php | 17 | ||||
-rw-r--r-- | ui/include/classes/validators/CNewValidator.php | 12 |
3 files changed, 31 insertions, 2 deletions
diff --git a/ui/app/controllers/CControllerPopupSlaExcludedDowntimeEdit.php b/ui/app/controllers/CControllerPopupSlaExcludedDowntimeEdit.php index 89714f059d3..c4fc0f67ed8 100644 --- a/ui/app/controllers/CControllerPopupSlaExcludedDowntimeEdit.php +++ b/ui/app/controllers/CControllerPopupSlaExcludedDowntimeEdit.php @@ -26,8 +26,8 @@ class CControllerPopupSlaExcludedDowntimeEdit extends CController { 'edit' => 'in 1', 'row_index' => 'required|int32', 'name' => 'string', - 'period_from' => 'int32', - 'period_to' => 'int32' + 'period_from' => 'uint64', + 'period_to' => 'uint64' ]; $ret = $this->validateInput($fields); diff --git a/ui/include/classes/parsers/CValidationRule.php b/ui/include/classes/parsers/CValidationRule.php index 5cac7b0f0c4..99aa253e0f2 100644 --- a/ui/include/classes/parsers/CValidationRule.php +++ b/ui/include/classes/parsers/CValidationRule.php @@ -66,6 +66,7 @@ class CValidationRule { && !$this->parseLE($buffer, $pos, $rule) && !$this->parseJson($buffer, $pos, $rule) && !$this->parseInt32($buffer, $pos, $rule) + && !$this->parseUInt64($buffer, $pos, $rule) && !$this->parseIn($buffer, $pos, $rule) && !$this->parseId($buffer, $pos, $rule) && !$this->parseGE($buffer, $pos, $rule) @@ -389,6 +390,22 @@ class CValidationRule { } /** + * uint64 + * + * 'uint64' => true + */ + private function parseUInt64($buffer, &$pos, &$rules) { + if (strncmp(substr($buffer, $pos), 'uint64', 6) != 0) { + return false; + } + + $pos += 6; + $rules['uint64'] = true; + + return true; + } + + /** * in <value1>[,...,<valueN>] * * 'in' => array('<value1>', ..., '<valueN>') diff --git a/ui/include/classes/validators/CNewValidator.php b/ui/include/classes/validators/CNewValidator.php index ab7a23ab9c1..0ee314f8f2b 100644 --- a/ui/include/classes/validators/CNewValidator.php +++ b/ui/include/classes/validators/CNewValidator.php @@ -141,6 +141,18 @@ class CNewValidator { } break; + case 'uint64': + if ((!is_string($value) && !is_numeric($value)) || !self::is_uint64($value)) { + $this->addError($fatal, + is_scalar($value) + ? _s('Incorrect value "%1$s" for "%2$s" field.', $value, $field) + : _s('Incorrect value for "%1$s" field.', $field) + ); + + return false; + } + break; + case 'id': if ((!is_string($value) && !is_numeric($value)) || !self::is_id($value)) { $this->addError($fatal, |