Commit e5d57a43 authored by Franco Fichtner's avatar Franco Fichtner

Revert "php: remove ctype dependency; closes #917"

This reverts commit ed81dd30.
The state of digit validation is highly controversial.  I give
up.  :)
parent 3f8c0fea
......@@ -117,6 +117,7 @@ CORE_DEPENDS?= apinger \
phalcon \
php-suhosin \
php56 \
php56-ctype \
php56-curl \
php56-dom \
php56-filter \
......
......@@ -119,7 +119,7 @@ function unlock($cfglckkey = null)
/* validate non-negative numeric string, or equivalent numeric variable */
function is_numericint($arg)
{
return (((is_int($arg) && $arg >= 0) || (is_string($arg) && strlen($arg) > 0 && is_numeric($arg))) ? true : false);
return (((is_int($arg) && $arg >= 0) || (is_string($arg) && strlen($arg) > 0 && ctype_digit($arg))) ? true : false);
}
/* return the subnet address given a host address and a subnet bit count */
......@@ -523,7 +523,7 @@ function is_port($port)
if (getservbyname($port, "tcp") || getservbyname($port, "udp")) {
return true;
}
if (!is_numeric($port)) {
if (!ctype_digit($port)) {
return false;
} elseif ((intval($port) < 1) || (intval($port) > 65535)) {
return false;
......
......@@ -52,6 +52,8 @@ PHPMODULES="$PHPMODULES hash mcrypt"
PHPMODULES="$PHPMODULES session"
# Extra sanity seatbelts
PHPMODULES="$PHPMODULES suhosin"
# Firewall rules edit
PHPMODULES="$PHPMODULES ctype"
# Page compression
PHPMODULES="$PHPMODULES zlib"
# Databases
......
......@@ -76,12 +76,13 @@ class Config extends Singleton
private function isArraySequential($arrayData)
{
foreach ($arrayData as $key => $value) {
if (!is_numeric(strval($key))) {
if (!ctype_digit(strval($key))) {
return false;
}
}
return true;
}
/**
......
......@@ -51,7 +51,7 @@ class IntegerValidator extends Validator implements ValidatorInterface
{
$value = $validator->getValue($attribute);
$msg = $this->getOption('message');
if (is_numeric(strval($value)) == false or (string)((int)$value) !== (string)$value) {
if (ctype_digit(strval(($value))) == false or (string)((int)$value) !== (string)$value) {
$validator->appendMessage(new Message($msg, $attribute, 'IntegerValidator'));
return false;
}
......
......@@ -84,8 +84,8 @@ class NetworkValidator extends Validator implements ValidatorInterface
// split network
if (strpos($value, "/") !== false) {
$parts = explode("/", $value);
if (count($parts) > 2 || !is_numeric($parts[1])) {
// more parts than expected or second part is not numeric
if (count($parts) > 2 || !ctype_digit($parts[1])) {
// more parts then expected or second part is not numeric
$result = false;
} else {
$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