From ff8131edbc89b8260c3fb6b383267cd971640da5 Mon Sep 17 00:00:00 2001 From: DevelArt IV Date: Thu, 29 Sep 2022 11:56:42 +0200 Subject: [PATCH 1/2] isNumber() bugfix --- library/Zend/Locale/Format.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/Zend/Locale/Format.php b/library/Zend/Locale/Format.php index c781621466..4ee24b5b51 100644 --- a/library/Zend/Locale/Format.php +++ b/library/Zend/Locale/Format.php @@ -516,6 +516,10 @@ public static function isNumber($input, array $options = []) if (!self::_getUniCodeSupport()) { trigger_error("Sorry, your PCRE extension does not support UTF8 which is needed for the I18N core", E_USER_NOTICE); } + + if(is_numeric($input)) { + return TRUE; + } $options = self::_checkOptions($options) + self::$_options; @@ -524,7 +528,10 @@ public static function isNumber($input, array $options = []) $regexs = Zend_Locale_Format::_getRegexForType('decimalnumber', $options); $regexs = array_merge($regexs, Zend_Locale_Format::_getRegexForType('scientificnumber', $options)); - if (!empty($input) && ($input[0] == $symbols['decimal'])) { + + $firstChar = substr($input,0,1); + + if (!empty($input) && ($firstChar == $symbols['decimal'])) { $input = 0 . $input; } foreach ($regexs as $regex) { From d7f99e7ccb2bf3aba4248be5d4c5510b80ade307 Mon Sep 17 00:00:00 2001 From: DevelArt IV Date: Mon, 24 Jul 2023 19:21:01 +0200 Subject: [PATCH 2/2] Updated Format::isNumber() to comply with FloatTest UTs --- library/Zend/Locale/Format.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Zend/Locale/Format.php b/library/Zend/Locale/Format.php index 395aecbd1d..8a5c8d5232 100644 --- a/library/Zend/Locale/Format.php +++ b/library/Zend/Locale/Format.php @@ -517,8 +517,8 @@ public static function isNumber($input, array $options = []) trigger_error("Sorry, your PCRE extension does not support UTF8 which is needed for the I18N core", E_USER_NOTICE); } - if(is_numeric($input)) { - return TRUE; + if($input === null ) { + return FALSE; } $options = self::_checkOptions($options) + self::$_options;