diff options
author | Renato Botelho <renato@netgate.com> | 2016-06-08 18:08:22 -0400 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-06-08 18:08:22 -0400 |
commit | 1a6fc86d35b7d9d43d79a0125980ac83f6232fa0 (patch) | |
tree | 70d92644e8f20c02b8d740f4eb085c0ff7702ebf /src | |
parent | 0067c9a75095d9010d47b580f2798dc3029c7add (diff) | |
download | pfsense-1a6fc86d35b7d9d43d79a0125980ac83f6232fa0.zip pfsense-1a6fc86d35b7d9d43d79a0125980ac83f6232fa0.tar.gz |
Implement pkg_valid_name()
Diffstat (limited to 'src')
-rw-r--r-- | src/etc/inc/pkg-utils.inc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/etc/inc/pkg-utils.inc b/src/etc/inc/pkg-utils.inc index daa0a55..6f3f18e 100644 --- a/src/etc/inc/pkg-utils.inc +++ b/src/etc/inc/pkg-utils.inc @@ -83,6 +83,14 @@ if (!function_exists("pkg_debug")) { } } +/* Validate if pkg name is valid */ +function pkg_valid_name($pkgname) { + global $g; + + $pattern = "/^{$g['pkg_prefix']}[a-zA-Z0-9\.\-_]+$/"; + return preg_match($pattern, $pkgname); +} + /* Remove pkg_prefix from package name if it's present */ function pkg_remove_prefix(&$pkg_name) { global $g; |