The filter extensinon will segfault if a callback filter returns
FALSE, this little patch fixes that.
There is also no way to set default value if the callback fails
because of a design flow. When dealing with callbacks the 'options'
key in the options parameters just be a valid callback, but to set a
default value then this key must be a array that includes the key
'default'.
Test case:
function filter_test($str) { return FALSE; }
var_dump(filter_var('durty/boy', FILTER_CALLBACK, array(
'options' => 'filter_test',
)));
Arnar Mar Sig
Erm, the attachement got stripped away, heres the patch..
--- php-5.2.5/ext/filter/filter.c 2007-04-04 20:50:26.000000000 +0000
+++ php-5.2.5-fixed/ext/filter/filter.c 2008-02-24 15:14:19.000000000
+0000
@@ -322,7 +322,7 @@
filter_func.function(*value, flags, options, charset TSRMLS_CC);
if (
-
options &&
-
options && (Z_TYPE_P(options) == IS_ARRAY || Z_TYPE_P(options)
== IS_OBJECT) &&
((flags & FILTER_NULL_ON_FAILURE
&& Z_TYPE_PP(value) ==
IS_NULL) ||
(!(flags & FILTER_NULL_ON_FAILURE) && Z_TYPE_PP(value) ==
IS_BOOL && Z_LVAL_PP(value) == 0)) &&
zend_hash_exists(HASH_OF(options), "default",
sizeof("default"))
Arnar Mar Sig
The filter extensinon will segfault if a callback filter returns
FALSE, this little patch fixes that.There is also no way to set default value if the callback fails
because of a design flow. When dealing with callbacks the 'options'
key in the options parameters just be a valid callback, but to set a
default value then this key must be a array that includes the key
'default'.Test case:
function filter_test($str) { return FALSE; }
var_dump(filter_var('durty/boy', FILTER_CALLBACK, array(
'options' => 'filter_test',
)));Arnar Mar Sig
Em Dom, 2008-02-24 às 15:48 +0000, Arnar Mar Sig escreveu:
Erm, the attachement got stripped away, heres the patch..
--- php-5.2.5/ext/filter/filter.c 2007-04-04 20:50:26.000000000 +0000
+++ php-5.2.5-fixed/ext/filter/filter.c 2008-02-24 15:14:19.000000000
+0000
@@ -322,7 +322,7 @@
filter_func.function(*value, flags, options, charset TSRMLS_CC);if (
options &&
options && (Z_TYPE_P(options) == IS_ARRAY || Z_TYPE_P(options)
== IS_OBJECT) &&
((flags &FILTER_NULL_ON_FAILURE
&& Z_TYPE_PP(value) ==
IS_NULL) ||
(!(flags & FILTER_NULL_ON_FAILURE) && Z_TYPE_PP(value) ==
IS_BOOL && Z_LVAL_PP(value) == 0)) &&
zend_hash_exists(HASH_OF(options), "default",
sizeof("default"))Arnar Mar Sig
Fixed in CVS.
Thanks.
--
Regards,
Felipe Pena.
Hi Arnar, Felipe!
Em Dom, 2008-02-24 às 15:48 +0000, Arnar Mar Sig escreveu:
Fixed in CVS.
Thanks for your patches and quick reaction :)
Can you add a test while being at it please?
Cheers,
Em Dom, 2008-02-24 às 19:45 +0100, Pierre Joye escreveu:
Hi Arnar, Felipe!
Em Dom, 2008-02-24 às 15:48 +0000, Arnar Mar Sig escreveu:
Fixed in CVS.Thanks for your patches and quick reaction :)
Can you add a test while being at it please?
Cheers,
Done! ;)
Regards,
Felipe Pena.