{
if (Z_TYPE_P(zv) == IS_STRING) {
size_t len = Z_STRLEN_P(zv);
- zend_string *stripped = php_addcslashes(Z_STRVAL_P(zv), Z_STRLEN_P(zv), 1,
+ zend_string *stripped = php_addcslashes(Z_STRVAL_P(zv), Z_STRLEN_P(zv), 0,
ZEND_STRL("\0..\37\173\\\""));
if (len != stripped->len || strpbrk(stripped->val, "()<>@,;:\"[]?={} ")) {
}
#endif
- zend_hash_get_current_key_ex(Z_ARRVAL_P(zdata), &hkey.key, &hkey.h, NULL);
+ zend_hash_get_current_key(Z_ARRVAL_P(zdata), &hkey.key, &hkey.h);
if ((hkey.key && !zend_hash_exists(params, hkey.key))
|| (!hkey.key && !zend_hash_index_exists(params, hkey.h))
while (Z_TYPE_P(zdata_ptr) == IS_ARRAY && (test_ptr = zend_hash_get_current_data(Z_ARRVAL_P(zdata_ptr)))) {
if (Z_TYPE_P(test_ptr) == IS_ARRAY) {
/* now find key in ptr */
- if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_P(zdata_ptr), &hkey.key, &hkey.h, NULL)) {
+ if (HASH_KEY_IS_STRING == zend_hash_get_current_key(Z_ARRVAL_P(zdata_ptr), &hkey.key, &hkey.h)) {
+ zval *tmp_ptr = ptr;
+
if ((ptr = zend_hash_find(Z_ARRVAL_P(ptr), hkey.key))) {
zdata_ptr = test_ptr;
} else {
+ ptr = tmp_ptr;
Z_TRY_ADDREF_P(test_ptr);
ptr = zend_hash_update(Z_ARRVAL_P(ptr), hkey.key, test_ptr);
break;
zval_dtor(ptr);
array_init(ptr);
}
- if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_P(zdata_ptr), &hkey.key, &hkey.h, NULL)) {
+ if (HASH_KEY_IS_STRING == zend_hash_get_current_key(Z_ARRVAL_P(zdata_ptr), &hkey.key, &hkey.h)) {
ptr = zend_hash_update(Z_ARRVAL_P(ptr), hkey.key, test_ptr);
} else if (hkey.h) {
ptr = zend_hash_index_update(Z_ARRVAL_P(ptr), hkey.h, test_ptr);
ZVAL_NULL(&key);
sanitize_key(opts->flags, state->param.str, state->param.len, &key, &rfc5987);
state->rfc5987 = rfc5987;
- if (Z_TYPE(key) != IS_STRING) {
+ if (Z_TYPE(key) == IS_ARRAY) {
merge_param(params, &key, &state->current.val, &state->current.args);
- } else if (Z_STRLEN(key)) {
- array_init_size(&prm, 2);
+ } else if (Z_TYPE(key) == IS_STRING && Z_STRLEN(key)) {
+ //array_init_size(&prm, 2);
+ array_init(&prm);
if (!Z_ISUNDEF(opts->defval)) {
ZVAL_COPY_VALUE(&val, &opts->defval);
} else {
state->current.val = zend_hash_str_update(Z_ARRVAL(prm), "value", lenof("value"), &val);
}
-
- array_init_size(&arg, 3);
+ //array_init_size(&arg, 3);
+ array_init(&arg);
state->current.args = zend_hash_str_update(Z_ARRVAL(prm), "arguments", lenof("arguments"), &arg);
state->current.param = zend_symtable_str_update(params, Z_STRVAL(key), Z_STRLEN(key), &prm);
}
php_http_arrkey_t key = {0};
if ((zdata = zend_hash_get_current_data(ht))
- && HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(ht, &key.key, &key.h, NULL)
+ && HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(ht, &key.key, &key.h)
) {
php_http_arrkey_stringify(&key, NULL);
php_http_buffer_appendf(buf, "*%.*sutf-8'%.*s'",
zvalue = tmp;
} else if (zvalue == zparam) {
continue;
+ } else {
+ zvalue = zparam;
}
- zvalue = zparam;
}
if (Z_TYPE_P(zvalue) == IS_ARRAY) {
php_http_params_token_t **php_http_params_separator_init(zval *zv)
{
- zval *sep;
+ zval *sep, ztmp;
php_http_params_token_t **ret, **tmp;
if (!zv) {
return NULL;
}
- SEPARATE_ZVAL(zv);
+ ZVAL_DUP(&ztmp, zv);
+ zv = &ztmp;
convert_to_array(zv);
+
ret = ecalloc(zend_hash_num_elements(Z_ARRVAL_P(zv)) + 1, sizeof(*ret));
tmp = ret;
zend_string_release(zs);
}
ZEND_HASH_FOREACH_END();
- zval_ptr_dtor(zv);
+
+ zval_ptr_dtor(&ztmp);
*tmp = NULL;
return ret;
default:
zs = zval_get_string(zparams);
if (zs->len) {
+ zval tmp;
+
php_http_params_opts_t opts = {
{zs->val, zs->len},
php_http_params_separator_init(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("param_sep"), 0)),
{{0}}, flags
};
- array_init(zparams);
- php_http_params_parse(Z_ARRVAL_P(zparams), &opts);
- zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), zparams);
+ array_init(&tmp);
+ php_http_params_parse(Z_ARRVAL(tmp), &opts);
+ zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), &tmp);
+ zval_ptr_dtor(&tmp);
php_http_params_separator_free(opts.param);
php_http_params_separator_free(opts.arg);
php_http_params_separator_free(opts.val);
}
+ zend_string_release(zs);
break;
}
} else {
- array_init(zparams);
- zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), zparams);
+ zval tmp;
+
+ array_init(&tmp);
+ zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), &tmp);
+ zval_ptr_dtor(&tmp);
}
}
zend_restore_error_handling(&zeh);
if (Z_TYPE_P(zparams) == IS_ARRAY) {
zend_symtable_del(Z_ARRVAL_P(zparams), name);
- zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), zparams);
}
}
}
zparams = zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), 0);
- SEPARATE_ZVAL(zparams);
convert_to_array(zparams);
if (name->len) {
if (Z_TYPE_P(nvalue) == IS_ARRAY) {
- zval *new_zparam;
-
if ((zparam = zend_symtable_find(Z_ARRVAL_P(zparams), name))) {
- new_zparam = zparam;
- SEPARATE_ZVAL(new_zparam);
- convert_to_array(new_zparam);
- array_join(Z_ARRVAL_P(nvalue), Z_ARRVAL_P(new_zparam), 0, 0);
+ convert_to_array(zparam);
+ array_join(Z_ARRVAL_P(nvalue), Z_ARRVAL_P(zparam), 0, 0);
} else {
- new_zparam = nvalue;
- Z_TRY_ADDREF_P(new_zparam);
+ Z_TRY_ADDREF_P(nvalue);
+ add_assoc_zval_ex(zparams, name->val, name->len, nvalue);
}
- add_assoc_zval_ex(zparams, name->val, name->len, new_zparam);
} else {
zval tmp;
if ((zparam = zend_symtable_find(Z_ARRVAL_P(zparams), name))) {
- tmp = *zparam;
- SEPARATE_ZVAL(&tmp);
+ ZVAL_DUP(&tmp, zparam);
convert_to_array(&tmp);
} else {
array_init(&tmp);
add_assoc_zval_ex(zparams, zs->val, zs->len, &arr);
zend_string_release(zs);
}
-
- zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), zparams);
- zval_ptr_dtor(zparams);
}
static zend_function_entry php_http_params_methods[] = {