--EXPECTF--
string(0) ""
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
+Warning: urldecode() expects parameter 1 to be string (Unicode or binary), array given in /home/dmitry/php/php6/Zend/tests/null_argument_001.php on line 6
NULL
string(1) "1"
string(0) ""
-Warning: urldecode() expects parameter 1 to be binary string, object given in %s on line %d
+Warning: urldecode() expects parameter 1 to be string (Unicode or binary), object given in /home/dmitry/php/php6/Zend/tests/null_argument_001.php on line 9
NULL
-Warning: urldecode() expects parameter 1 to be binary string, resource given in %s on line %d
+Warning: urldecode() expects parameter 1 to be string (Unicode or binary), resource given in /home/dmitry/php/php6/Zend/tests/null_argument_001.php on line 12
NULL
Done
"",
'',
+ // non ASCII UNICODE
+ "привет",
+
// object data
new stdclass(),
?>
--EXPECTF--
*** Testing rawurldecode() : usage variations ***
-Error: 8 - Undefined variable: undefined_var, %s(64)
-Error: 8 - Undefined variable: unset_var, %s(67)
+Error: 8 - Undefined variable: undefined_var, %s(%d)
+Error: 8 - Undefined variable: unset_var, %s(%d)
Arg value 0
string(1) "0"
Arg value 0.5
string(3) "0.5"
-Error: 8 - Array to string conversion, %s(73)
+Error: 8 - Array to string conversion, %s(%d)
Arg value Array
-Error: 2 - rawurldecode() expects parameter 1 to be binary string, array given, %s(74)
+Error: 2 - rawurldecode() expects parameter 1 to be string (Unicode or binary), array given, %s(%d)
NULL
-Error: 8 - Array to string conversion, %s(73)
+Error: 8 - Array to string conversion, %s(%d)
Arg value Array
-Error: 2 - rawurldecode() expects parameter 1 to be binary string, array given, %s(74)
+Error: 2 - rawurldecode() expects parameter 1 to be string (Unicode or binary), array given, %s(%d)
NULL
-Error: 8 - Array to string conversion, %s(73)
+Error: 8 - Array to string conversion, %s(%d)
Arg value Array
-Error: 2 - rawurldecode() expects parameter 1 to be binary string, array given, %s(74)
+Error: 2 - rawurldecode() expects parameter 1 to be string (Unicode or binary), array given, %s(%d)
NULL
-Error: 8 - Array to string conversion, %s(73)
+Error: 8 - Array to string conversion, %s(%d)
Arg value Array
-Error: 2 - rawurldecode() expects parameter 1 to be binary string, array given, %s(74)
+Error: 2 - rawurldecode() expects parameter 1 to be string (Unicode or binary), array given, %s(%d)
NULL
-Error: 8 - Array to string conversion, %s(73)
+Error: 8 - Array to string conversion, %s(%d)
Arg value Array
-Error: 2 - rawurldecode() expects parameter 1 to be binary string, array given, %s(74)
+Error: 2 - rawurldecode() expects parameter 1 to be string (Unicode or binary), array given, %s(%d)
NULL
Arg value
string(0) ""
Arg value
-Error: 2 - rawurldecode() expects parameter 1 to be strictly a binary string, Unicode string given, %s(74)
-NULL
+string(0) ""
Arg value
-Error: 2 - rawurldecode() expects parameter 1 to be strictly a binary string, Unicode string given, %s(74)
-NULL
-Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
+string(0) ""
+
+Arg value привет
+Error: 2 - rawurldecode(): Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received, %s(%d)
+bool(false)
+Error: 4096 - Object of class stdClass could not be converted to string, %s(%d)
Arg value
-Error: 2 - rawurldecode() expects parameter 1 to be binary string, object given, %s(74)
+Error: 2 - rawurldecode() expects parameter 1 to be string (Unicode or binary), object given, %s(%d)
NULL
Arg value
"",
'',
+ // non ASCII UNICODE
+ "привет",
+
// object data
new stdclass(),
?>
--EXPECTF--
*** Testing urldecode() : usage variations ***
-Error: 8 - Undefined variable: undefined_var, %s(64)
-Error: 8 - Undefined variable: unset_var, %s(67)
+Error: 8 - Undefined variable: undefined_var, %s(%d)
+Error: 8 - Undefined variable: unset_var, %s(%d)
Arg value 0
string(1) "0"
Arg value 0.5
string(3) "0.5"
-Error: 8 - Array to string conversion, %s(73)
+Error: 8 - Array to string conversion, %s(%d)
Arg value Array
-Error: 2 - urldecode() expects parameter 1 to be binary string, array given, %s(74)
+Error: 2 - urldecode() expects parameter 1 to be string (Unicode or binary), array given, %s(%d)
NULL
-Error: 8 - Array to string conversion, %s(73)
+Error: 8 - Array to string conversion, %s(%d)
Arg value Array
-Error: 2 - urldecode() expects parameter 1 to be binary string, array given, %s(74)
+Error: 2 - urldecode() expects parameter 1 to be string (Unicode or binary), array given, %s(%d)
NULL
-Error: 8 - Array to string conversion, %s(73)
+Error: 8 - Array to string conversion, %s(%d)
Arg value Array
-Error: 2 - urldecode() expects parameter 1 to be binary string, array given, %s(74)
+Error: 2 - urldecode() expects parameter 1 to be string (Unicode or binary), array given, %s(%d)
NULL
-Error: 8 - Array to string conversion, %s(73)
+Error: 8 - Array to string conversion, %s(%d)
Arg value Array
-Error: 2 - urldecode() expects parameter 1 to be binary string, array given, %s(74)
+Error: 2 - urldecode() expects parameter 1 to be string (Unicode or binary), array given, %s(%d)
NULL
-Error: 8 - Array to string conversion, %s(73)
+Error: 8 - Array to string conversion, %s(%d)
Arg value Array
-Error: 2 - urldecode() expects parameter 1 to be binary string, array given, %s(74)
+Error: 2 - urldecode() expects parameter 1 to be string (Unicode or binary), array given, %s(%d)
NULL
Arg value
string(0) ""
Arg value
-Error: 2 - urldecode() expects parameter 1 to be strictly a binary string, Unicode string given, %s(74)
-NULL
+string(0) ""
Arg value
-Error: 2 - urldecode() expects parameter 1 to be strictly a binary string, Unicode string given, %s(74)
-NULL
-Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
+string(0) ""
+
+Arg value привет
+Error: 2 - urldecode(): Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received, %s(%d)
+bool(false)
+Error: 4096 - Object of class stdClass could not be converted to string, %s(%d)
Arg value
-Error: 2 - urldecode() expects parameter 1 to be binary string, object given, %s(74)
+Error: 2 - urldecode() expects parameter 1 to be string (Unicode or binary), object given, %s(%d)
NULL
Arg value
Decodes URL-encoded string */
PHP_FUNCTION(urldecode)
{
- char *in_str, *out_str;
+ zstr in_str;
+ char *out_str;
int in_str_len, out_str_len;
+ zend_uchar in_str_type;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &in_str,
- &in_str_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t", &in_str,
+ &in_str_len, &in_str_type) == FAILURE) {
return;
}
- out_str = estrndup(in_str, in_str_len);
+ if (in_str_type == IS_UNICODE) {
+ in_str.s = zend_unicode_to_ascii(in_str.u, in_str_len TSRMLS_CC);
+ if (!in_str.s) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received");
+ RETURN_FALSE;
+ }
+ }
+
+ out_str = estrndup(in_str.s, in_str_len);
out_str_len = php_url_decode(out_str, in_str_len);
+ if (in_str_type == IS_UNICODE) {
+ efree(in_str.s);
+ }
+
RETURN_STRINGL(out_str, out_str_len, 0);
}
/* }}} */
Decodes URL-encodes string */
PHP_FUNCTION(rawurldecode)
{
- char *in_str, *out_str;
+ zstr in_str;
+ char *out_str;
int in_str_len, out_str_len;
+ zend_uchar in_str_type;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &in_str,
- &in_str_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t", &in_str,
+ &in_str_len, &in_str_type) == FAILURE) {
return;
}
- out_str = estrndup(in_str, in_str_len);
+ if (in_str_type == IS_UNICODE) {
+ in_str.s = zend_unicode_to_ascii(in_str.u, in_str_len TSRMLS_CC);
+ if (!in_str.s) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received");
+ RETURN_FALSE;
+ }
+ }
+
+ out_str = estrndup(in_str.s, in_str_len);
out_str_len = php_raw_url_decode(out_str, in_str_len);
+ if (in_str_type == IS_UNICODE) {
+ efree(in_str.s);
+ }
+
RETURN_STRINGL(out_str, out_str_len, 0);
}
/* }}} */