From: Marcin Haba Date: Sat, 2 Dec 2017 14:57:40 +0000 (+0100) Subject: baculum: Add state, number, boolean and id validators X-Git-Tag: Release-9.0.7~17 X-Git-Url: https://git.sur5r.net/?p=bacula%2Fbacula;a=commitdiff_plain;h=e26b9d05c8c05fccef0d89c50759d4df75fbd359;ds=sidebyside baculum: Add state, number, boolean and id validators --- 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) {