From e26b9d05c8c05fccef0d89c50759d4df75fbd359 Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Sat, 2 Dec 2017 15:57:40 +0100 Subject: [PATCH] baculum: Add state, number, boolean and id validators --- .../protected/Common/Class/Miscellaneous.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gui/baculum/protected/Common/Class/Miscellaneous.php b/gui/baculum/protected/Common/Class/Miscellaneous.php index 0d9871bc15..eedac61094 100644 --- a/gui/baculum/protected/Common/Class/Miscellaneous.php +++ b/gui/baculum/protected/Common/Class/Miscellaneous.php @@ -185,8 +185,24 @@ class Miscellaneous extends TModule { return (preg_match('/^[\w:\.\-\s]{1,127}$/', $name) === 1); } + public function isValidState($state) { + return (preg_match('/^\w+$/', $state) === 1); + } + + public function isValidNumber($num) { + return (preg_match('/^\d+$/', $num) === 1); + } + + public function isValidBoolean($val) { + return (preg_match('/^(yes|no|0|1|true|false)$/', $val) === 1); + } + + public function isValidId($id) { + return (preg_match('/^\d+$/', $id) === 1); + } + public function isValidPath($path) { - return (preg_match('/^[\p{L}\p{N}\p{Z}\[\]\(\)\-\+\/\\\:\.#~_,{}!]{1,1000}$/', $path) === 1); + return (preg_match('/^[\p{L}\p{N}\p{Z}\[\]\(\)\-\+\/\\\:\.#~_,{}!]{0,1000}$/', $path) === 1); } public function isValidReplace($replace) { -- 2.39.2