From: Ilia Alshanetsky Date: Thu, 14 Sep 2006 17:48:11 +0000 (+0000) Subject: MFB: Make float filter handle things like 02.324 properly X-Git-Tag: RELEASE_1_0_0RC1~1672 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0fff2d8d45570d86120bbe85a84d1035de488639;p=php MFB: Make float filter handle things like 02.324 properly --- diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index ddb91dbb74..e3f85f95b2 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -332,9 +332,8 @@ void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ ret_val = 0.0; - if (*str == '0') { - /* leading zeros */ - while (*(str++) == '0'); + while (*str == '0') { + str++; } if (*str == dec_sep) { diff --git a/ext/filter/tests/bug7715.phpt b/ext/filter/tests/bug7715.phpt index 9e1206f6a5..864a41b1fb 100644 --- a/ext/filter/tests/bug7715.phpt +++ b/ext/filter/tests/bug7715.phpt @@ -9,7 +9,8 @@ $data = array( '.4', '-.4', '1000000000000', - '-1000000000000' + '-1000000000000', + '02.324' ); foreach ($data as $val) { $res = filter_data($val, FILTER_VALIDATE_FLOAT); @@ -25,3 +26,4 @@ float(0.4) float(-0.4) float(1.0E+12) float(-1.0E+12) +float(2.324)