Commit ed81dd30 authored by Franco Fichtner's avatar Franco Fichtner

php: remove ctype dependency; closes #917

Needs a bit of observation, but as far as I can see the only difference
is that is_numeric() will also take int values and return true for them,
ctype_digit() will only return true for string values that have digits.
parent 160c1245
...@@ -119,7 +119,6 @@ CORE_DEPENDS?= apinger \ ...@@ -119,7 +119,6 @@ CORE_DEPENDS?= apinger \
php-suhosin \ php-suhosin \
php56 \ php56 \
php56-bcmath \ php56-bcmath \
php56-ctype \
php56-curl \ php56-curl \
php56-dom \ php56-dom \
php56-filter \ php56-filter \
......
...@@ -119,7 +119,7 @@ function unlock($cfglckkey = null) ...@@ -119,7 +119,7 @@ function unlock($cfglckkey = null)
/* validate non-negative numeric string, or equivalent numeric variable */ /* validate non-negative numeric string, or equivalent numeric variable */
function is_numericint($arg) function is_numericint($arg)
{ {
return (((is_int($arg) && $arg >= 0) || (is_string($arg) && strlen($arg) > 0 && ctype_digit($arg))) ? true : false); return (((is_int($arg) && $arg >= 0) || (is_string($arg) && strlen($arg) > 0 && is_numeric($arg))) ? true : false);
} }
/* return the subnet address given a host address and a subnet bit count */ /* return the subnet address given a host address and a subnet bit count */
...@@ -523,7 +523,7 @@ function is_port($port) ...@@ -523,7 +523,7 @@ function is_port($port)
if (getservbyname($port, "tcp") || getservbyname($port, "udp")) { if (getservbyname($port, "tcp") || getservbyname($port, "udp")) {
return true; return true;
} }
if (!ctype_digit($port)) { if (!is_numeric($port)) {
return false; return false;
} elseif ((intval($port) < 1) || (intval($port) > 65535)) { } elseif ((intval($port) < 1) || (intval($port) > 65535)) {
return false; return false;
......
...@@ -52,8 +52,6 @@ PHPMODULES="$PHPMODULES hash mcrypt" ...@@ -52,8 +52,6 @@ PHPMODULES="$PHPMODULES hash mcrypt"
PHPMODULES="$PHPMODULES session" PHPMODULES="$PHPMODULES session"
# Extra sanity seatbelts # Extra sanity seatbelts
PHPMODULES="$PHPMODULES suhosin" PHPMODULES="$PHPMODULES suhosin"
# Firewall rules edit
PHPMODULES="$PHPMODULES ctype"
# Page compression # Page compression
PHPMODULES="$PHPMODULES zlib" PHPMODULES="$PHPMODULES zlib"
# Databases # Databases
......
...@@ -76,13 +76,12 @@ class Config extends Singleton ...@@ -76,13 +76,12 @@ class Config extends Singleton
private function isArraySequential($arrayData) private function isArraySequential($arrayData)
{ {
foreach ($arrayData as $key => $value) { foreach ($arrayData as $key => $value) {
if (!ctype_digit(strval($key))) { if (!is_numeric(strval($key))) {
return false; return false;
} }
} }
return true; return true;
} }
/** /**
......
...@@ -51,7 +51,7 @@ class IntegerValidator extends Validator implements ValidatorInterface ...@@ -51,7 +51,7 @@ class IntegerValidator extends Validator implements ValidatorInterface
{ {
$value = $validator->getValue($attribute); $value = $validator->getValue($attribute);
$msg = $this->getOption('message'); $msg = $this->getOption('message');
if (ctype_digit(strval(($value))) == false or (string)((int)$value) !== (string)$value) { if (is_numeric(strval($value)) == false or (string)((int)$value) !== (string)$value) {
$validator->appendMessage(new Message($msg, $attribute, 'IntegerValidator')); $validator->appendMessage(new Message($msg, $attribute, 'IntegerValidator'));
return false; return false;
} }
......
...@@ -84,8 +84,8 @@ class NetworkValidator extends Validator implements ValidatorInterface ...@@ -84,8 +84,8 @@ class NetworkValidator extends Validator implements ValidatorInterface
// split network // split network
if (strpos($value, "/") !== false) { if (strpos($value, "/") !== false) {
$parts = explode("/", $value); $parts = explode("/", $value);
if (count($parts) > 2 || !ctype_digit($parts[1])) { if (count($parts) > 2 || !is_numeric($parts[1])) {
// more parts then expected or second part is not numeric // more parts than expected or second part is not numeric
$result = false; $result = false;
} else { } else {
$mask = $parts[1]; $mask = $parts[1];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment