From fbe122d0c029f254019d6ebb53c9b85706d0a1a1 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Wed, 16 Jan 2008 23:59:30 +0000 Subject: added some extra protection in ctype_ function overrides to make return values match PHP's native methods for non-string types and empty strings --- system/codeigniter/Compat.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'system/codeigniter/Compat.php') diff --git a/system/codeigniter/Compat.php b/system/codeigniter/Compat.php index 3c5f70d60..108b0a1aa 100644 --- a/system/codeigniter/Compat.php +++ b/system/codeigniter/Compat.php @@ -55,6 +55,11 @@ if (! function_exists('ctype_digit')) { function ctype_digit($str) { + if (! is_string($str) OR $str == '') + { + return FALSE; + } + return ! preg_match('/[^0-9]/', $str); } } @@ -75,6 +80,11 @@ if (! function_exists('ctype_alnum')) { function ctype_alnum($str) { + if (! is_string($str) OR $str == '') + { + return FALSE; + } + return ! preg_match('/[^0-9a-z]/i', $str); } } -- cgit v1.2.3-24-g4f1b