cvs: ZendEngine2 / zend_API.c /tests null_argument_001.phpt

[email protected] ("Antony Dovgal")
Newsgroups php.zend-engine.cvs
Message-ID <cvstony20011206522548@cvsserver>
tony2001		Wed Mar 26 09:09:08 2008 UTC

  Added files:                 
    /ZendEngine2/tests	null_argument_001.phpt 

  Modified files:              
    /ZendEngine2	zend_API.c 
  Log:
  allow NULL argument to be passed where binary string expected
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.466&r2=1.467&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.466 ZendEngine2/zend_API.c:1.467
--- ZendEngine2/zend_API.c:1.466	Tue Mar 25 13:04:22 2008
+++ ZendEngine2/zend_API.c	Wed Mar 26 09:09:08 2008
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_API.c,v 1.466 2008/03/25 13:04:22 dmitry Exp $ */
+/* $Id: zend_API.c,v 1.467 2008/03/26 09:09:08 tony2001 Exp $ */
 
 #include "zend.h"
 #include "zend_execute.h"
@@ -476,7 +476,7 @@
 							*p = Z_STRVAL_PP(arg);
 							*pl = Z_STRLEN_PP(arg);
 							break;
-						} else if (c == 'S') {
+						} else if (c == 'S' && Z_TYPE_PP(arg) != IS_NULL /* NULL is ok */) {
 							return "strictly a binary string";
 						}
 						/* fall through */

http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/null_argument_001.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/null_argument_001.phpt
+++ ZendEngine2/tests/null_argument_001.phpt
--TEST--
NULL argument is allowed where binary string expected
--FILE--
<?php

var_dump(urldecode(null));
var_dump(urldecode(b""));
var_dump(urldecode(""));
var_dump(urldecode(array()));
var_dump(urldecode(1));
var_dump(urldecode(false));
var_dump(urldecode(new stdclass));

$fp = fopen(__FILE__, "r");
var_dump(urldecode($fp));

echo "Done\n";
?>
--EXPECTF--	
string(0) ""
string(0) ""
string(0) ""

Warning: urldecode() expects parameter 1 to be string, array given in %s on line %d
NULL
string(1) "1"
string(0) ""

Warning: urldecode() expects parameter 1 to be string, object given in %s on line %d
NULL

Warning: urldecode() expects parameter 1 to be string, resource given in %s on line %d
NULL
Done
--UEXPECTF--
string(0) ""
string(0) ""

Warning: urldecode() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d
NULL

Warning: urldecode() expects parameter 1 to be binary string, array given in %s on line %d
NULL
string(1) "1"
string(0) ""

Warning: urldecode() expects parameter 1 to be binary string, object given in %s on line %d
NULL

Warning: urldecode() expects parameter 1 to be binary string, resource given in %s on line %d
NULL
Done
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.