]> granicus.if.org Git - php/commitdiff
MFB: Make float filter handle things like 02.324 properly
authorIlia Alshanetsky <iliaa@php.net>
Thu, 14 Sep 2006 17:48:11 +0000 (17:48 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 14 Sep 2006 17:48:11 +0000 (17:48 +0000)
ext/filter/logical_filters.c
ext/filter/tests/bug7715.phpt

index ddb91dbb74ea980d11af4c2f7f44b69cc077533e..e3f85f95b237a0ae4c8b9e40d0a5bc005843eaa8 100644 (file)
@@ -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) {
index 9e1206f6a5fea0840edcbac7500e188162ec51ca..864a41b1fbdadcc6c1b94a5f0039c676bf6d9a3e 100644 (file)
@@ -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)