summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2006-08-31 18:29:29 +0000
committerPierre Joye <pajoye@php.net>2006-08-31 18:29:29 +0000
commit72820abd7ba77a4afb1c0086caf91d3a5841634c (patch)
treea9e098e4e677fd57c35e69bf81cd1e3deff74777
parent75b8cd741ba23dbf1ae75b50484d69d1aa70e7f3 (diff)
downloadphp-git-72820abd7ba77a4afb1c0086caf91d3a5841634c.tar.gz
- MFH: pecl bug #8316,
empty strings are not int or float, return false (due to popular demand)
-rw-r--r--ext/filter/logical_filters.c27
-rw-r--r--ext/filter/tests/010.phpt4
-rw-r--r--ext/filter/tests/013.phpt2
-rw-r--r--ext/filter/tests/filter_data.phpt4
4 files changed, 15 insertions, 22 deletions
diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c
index 0ce72313d1..ddb91dbb74 100644
--- a/ext/filter/logical_filters.c
+++ b/ext/filter/logical_filters.c
@@ -173,6 +173,14 @@ void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
FETCH_LONG_OPTION(max_range, "max_range");
FETCH_LONG_OPTION(option_flags, "flags");
+ len = Z_STRLEN_P(value);
+
+ if (len == 0) {
+ zval_dtor(value);
+ ZVAL_BOOL(value, 0);
+ return;
+ }
+
if (option_flags_set && (option_flags & FILTER_FLAG_ALLOW_OCTAL)) {
allow_octal = 1;
}
@@ -181,21 +189,6 @@ void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
allow_hex = 1;
}
- len = Z_STRLEN_P(value);
-
- if (len == 0) {
- if ((min_range_set && (0 < min_range)) || (max_range_set && (0 > max_range))) {
- zval_dtor(value);
- ZVAL_BOOL(value, 0);
- return;
- } else {
- zval_dtor(value);
- Z_TYPE_P(value) = IS_LONG;
- Z_LVAL_P(value) = 0;
- return;
- }
- }
-
/* Start the validating loop */
p = Z_STRVAL_P(value);
ctx_value = 0;
@@ -245,6 +238,7 @@ void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
} else {
zval_dtor(value);
ZVAL_BOOL(value, 0);
+ return;
}
/* returns true for "1", "true", "on" and "yes"
@@ -292,8 +286,7 @@ void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
if (len < 1) {
zval_dtor(value);
- Z_TYPE_P(value) = IS_DOUBLE;
- Z_DVAL_P(value) = 0;
+ ZVAL_BOOL(value, 0);
return;
}
diff --git a/ext/filter/tests/010.phpt b/ext/filter/tests/010.phpt
index eaded25b65..c78acd6779 100644
--- a/ext/filter/tests/010.phpt
+++ b/ext/filter/tests/010.phpt
@@ -21,7 +21,7 @@ array(7) {
[1]=>
int(1)
[2]=>
- int(0)
+ bool(false)
[3]=>
int(-23234)
[4]=>
@@ -38,7 +38,7 @@ array(7) {
[1]=>
float(1.7)
[2]=>
- float(0)
+ bool(false)
[3]=>
float(-23234.123)
[4]=>
diff --git a/ext/filter/tests/013.phpt b/ext/filter/tests/013.phpt
index 696d321898..6c755c78b7 100644
--- a/ext/filter/tests/013.phpt
+++ b/ext/filter/tests/013.phpt
@@ -63,7 +63,7 @@ int(6)
bool(false)
bool(false)
int(-1)
-int(0)
+bool(false)
bool(false)
bool(false)
bool(false)
diff --git a/ext/filter/tests/filter_data.phpt b/ext/filter/tests/filter_data.phpt
index e907d02093..2fdd823438 100644
--- a/ext/filter/tests/filter_data.phpt
+++ b/ext/filter/tests/filter_data.phpt
@@ -46,7 +46,7 @@ int(123)
int(-123)
int(0)
int(123)
-int(0)
+bool(false)
float(-0.123)
float(0)
@@ -54,7 +54,7 @@ float(1.23)
float(-1.23)
float(0)
float(1.23)
-float(0)
+bool(false)
bool(true)
bool(false)