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.2.0~159 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1af0bb2bcd2be730e3ce67614ca9eb442e4f491f;p=thirdparty%2Fbacula.git 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) {