svn: /php/php-src/branches/PHP_5_3_1/ext/filter/ filter.c tests/bug49274.phpt
| From: | Pierre-Alain Joye | Date: | Fri, 09 Oct 2009 17:32:53 +0000 |
| Subject: | svn: /php/php-src/branches/PHP_5_3_1/ext/filter/ filter.c tests/bug49274.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-60633@lists.php.net to get a copy of this message | ||
pajoye Fri, 09 Oct 2009 17:32:53 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=289434
Log:
- Merge: fix #49274, filter_var does not accept object without a toString implementation
Bug: http://bugs.php.net/49274 (Assigned) filter_var()
should accept objects without fatal error
Changed paths:
U php/php-src/branches/PHP_5_3_1/ext/filter/filter.c
A php/php-src/branches/PHP_5_3_1/ext/filter/tests/bug49274.phpt
Modified: php/php-src/branches/PHP_5_3_1/ext/filter/filter.c
===================================================================
--- php/php-src/branches/PHP_5_3_1/ext/filter/filter.c 2009-10-09 17:28:52 UTC (rev 289433)
+++ php/php-src/branches/PHP_5_3_1/ext/filter/filter.c 2009-10-09 17:32:53 UTC (rev 289434)
@@ -365,6 +365,19 @@
if (copy) {
SEPARATE_ZVAL(value);
}
+
+ /* #49274, fatal error with object without a toString method
+ Fails nicely instead of getting a recovarable fatal error. */
+ if (Z_TYPE_PP(value) == IS_OBJECT) {
+ zend_class_entry *ce;
+
+ ce = Z_OBJCE_PP(value);
+ if (!ce->__tostring) {
+ ZVAL_FALSE(*value);
+ return;
+ }
+ }
+
/* Here be strings */
convert_to_string(*value);
Added: php/php-src/branches/PHP_5_3_1/ext/filter/tests/bug49274.phpt
===================================================================
--- php/php-src/branches/PHP_5_3_1/ext/filter/tests/bug49274.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3_1/ext/filter/tests/bug49274.phpt 2009-10-09 17:32:53 UTC (rev
289434)
@@ -0,0 +1,10 @@
+--TEST--
+#49274, fatal error when an object does not implement toString
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+var_dump(filter_var(new stdClass, FILTER_VALIDATE_EMAIL));
+?>
+--EXPECTF--
+bool(false)