From 6e2add04eacbd84e3fd5add20d8808fb3cf574b3 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Thu, 14 Sep 2006 17:47:00 +0000 Subject: [PATCH] Make float filter handle things like 02.324 properly --- ext/filter/logical_filters.c | 5 ++--- ext/filter/tests/bug7715.phpt | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) 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) -- 2.40.0