Issues

ZF-2686: Unterminated Loop in Zend_Locale_Format::toNumber

Description


$number = '257';
$format = '#,##';  // wrong format
$locale = new Zend_Locale('de');
Zend_Locale_Format::toNumber($number, array('locale' => $locale, 'number_format'=>$format));

Comments

Please give us the following data for reproduction: OS, PHP Version, ZF SVN Version, set locale from php, bcmath enabled

Downgrading to should have and major as we have not got any data for reproduction.

This sort of issue has already been fixed in past for a specific OS so we are not sure if the reporter uses a old release or the failure is unfixed in his OS.

I have test it in the current revision 8180

  • PHP 5.2.5
  • WinXP SP2 -> setlocale(LC_ALL, 0) -> "LC_COLLATE=C;LC_CTYPE=German_Germany.1252;LC_MONETARY=C;LC_NUMERIC=C;LC_TIME=C" -> extension_loaded('bcmath') -> true
  • SuSE 10.3 -> comming soon tomorow

           // $number == 257
           // $seperation == -1
           // line 446 in Zend_Locale_Format:
            for ($x = iconv_strlen($number); $x > $seperation; $x -= $seperation) {
                if (iconv_substr($number, 0, $x - $seperation) !== "") {
                    $number = iconv_substr($number, 0, $x - $seperation) . $symbols['group']
                             . iconv_substr($number, $x - $seperation);
                }
            }

toNumber now throws an exception on wrong formats.... In your case an zero is missing.

Correct formats have to limit the number with an "0" before the precision. This was fixed with ZF-8229