summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/tests/null_argument_001.phpt52
-rw-r--r--Zend/zend_API.c2
2 files changed, 53 insertions, 1 deletions
diff --git a/Zend/tests/null_argument_001.phpt b/Zend/tests/null_argument_001.phpt
new file mode 100644
index 0000000000..9a5c707151
--- /dev/null
+++ b/Zend/tests/null_argument_001.phpt
@@ -0,0 +1,52 @@
+--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
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index d20439f70a..c386b66513 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -476,7 +476,7 @@ static char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, char **sp
*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 */