#define _KEY_IS(s) (key->key && key->key->len == sizeof(s)-1 && !strncasecmp(key->key->val, (s), key->key->len))
static void add_entry(php_http_cookie_list_t *list, char **allowed_extras, long flags, zend_hash_key *key, zval *val)
{
- zval *arg = val;
+ zval arg;
- Z_TRY_ADDREF_P(arg);
- SEPARATE_ZVAL(arg);
- convert_to_string(arg);
+ ZVAL_DUP(&arg, val);
+ convert_to_string(&arg);
if (!(flags & PHP_HTTP_COOKIE_PARSE_RAW)) {
- Z_STRLEN_P(arg) = php_raw_url_decode(Z_STRVAL_P(arg), Z_STRLEN_P(arg));
- zend_string_forget_hash_val(Z_STR_P(arg));
+ Z_STRLEN(arg) = php_raw_url_decode(Z_STRVAL(arg), Z_STRLEN(arg));
+ zend_string_forget_hash_val(Z_STR(arg));
}
if _KEY_IS("path") {
- PTR_SET(list->path, estrndup(Z_STRVAL_P(arg), Z_STRLEN_P(arg)));
+ PTR_SET(list->path, estrndup(Z_STRVAL(arg), Z_STRLEN(arg)));
} else if _KEY_IS("domain") {
- PTR_SET(list->domain, estrndup(Z_STRVAL_P(arg), Z_STRLEN_P(arg)));
+ PTR_SET(list->domain, estrndup(Z_STRVAL(arg), Z_STRLEN(arg)));
} else if _KEY_IS("expires") {
- char *date = estrndup(Z_STRVAL_P(arg), Z_STRLEN_P(arg));
+ char *date = estrndup(Z_STRVAL(arg), Z_STRLEN(arg));
list->expires = php_parse_date(date, NULL);
efree(date);
} else if _KEY_IS("max-age") {
- list->max_age = strtol(Z_STRVAL_P(arg), NULL, 10);
+ list->max_age = zval_get_long(val);
} else if _KEY_IS("secure") {
list->flags |= PHP_HTTP_COOKIE_SECURE;
} else if _KEY_IS("httpOnly") {
char **ae = allowed_extras;
for (; *ae; ++ae) {
if (!strncasecmp(*ae, tmp.key->val, tmp.key->len)) {
- zend_symtable_update(&list->extras, tmp.key, arg);
+ zend_symtable_update(&list->extras, tmp.key, &arg);
php_http_arrkey_dtor(&tmp);
return;
}
}
/* cookie */
- zend_symtable_update(&list->cookies, key->key, arg);
+ zend_symtable_update(&list->cookies, tmp.key, &arg);
php_http_arrkey_dtor(&tmp);
return;
}
- zval_ptr_dtor(arg);
+ zval_ptr_dtor(&arg);
}
php_http_cookie_list_t *php_http_cookie_list_parse(php_http_cookie_list_t *list, const char *str, size_t len, long flags, char **allowed_extras)
add_entry(list, NULL, flags, &k, val);
}
if ((args = zend_hash_str_find(Z_ARRVAL_P(param), ZEND_STRL("arguments"))) && Z_TYPE_P(args) == IS_ARRAY) {
- ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(args), arg_k.h, arg_k.key, arg) {
+ ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(args), arg_k.h, arg_k.key, arg)
+ {
add_entry(list, allowed_extras, flags, &arg_k, arg);
- } ZEND_HASH_FOREACH_END();
+ }
+ ZEND_HASH_FOREACH_END();
}
}
}
ht = HASH_OF(strct);
list = php_http_cookie_list_init(list);
- if ((tmp = zend_hash_str_find(ht, ZEND_STRL("cookies"))) && Z_TYPE_P(tmp) == IS_ARRAY){
+ if ((tmp = zend_hash_str_find_ind(ht, ZEND_STRL("cookies"))) && Z_TYPE_P(tmp) == IS_ARRAY){
array_copy(Z_ARRVAL_P(tmp), &list->cookies);
}
- if ((tmp = zend_hash_str_find(ht, ZEND_STRL("extras"))) && Z_TYPE_P(tmp) == IS_ARRAY){
+ if ((tmp = zend_hash_str_find_ind(ht, ZEND_STRL("extras"))) && Z_TYPE_P(tmp) == IS_ARRAY){
array_copy(Z_ARRVAL_P(tmp), &list->extras);
}
- if ((tmp = zend_hash_str_find(ht, ZEND_STRL("flags")))) {
+ if ((tmp = zend_hash_str_find_ind(ht, ZEND_STRL("flags")))) {
list->flags = zval_get_long(tmp);
}
- if ((tmp = zend_hash_str_find(ht, ZEND_STRL("expires")))) {
+ if ((tmp = zend_hash_str_find_ind(ht, ZEND_STRL("expires")))) {
if (Z_TYPE_P(tmp) == IS_LONG) {
list->expires = Z_LVAL_P(tmp);
} else {
zend_string_release(lstr);
}
}
- if ((tmp = zend_hash_str_find(ht, ZEND_STRL("max-age")))) {
+ if ((tmp = zend_hash_str_find_ind(ht, ZEND_STRL("max-age")))) {
if (Z_TYPE_P(tmp) == IS_LONG) {
list->max_age = Z_LVAL_P(tmp);
} else {
zend_string_release(lstr);
}
}
- if ((tmp = zend_hash_str_find(ht, ZEND_STRL("path")))) {
+ if ((tmp = zend_hash_str_find_ind(ht, ZEND_STRL("path")))) {
zend_string *str = zval_get_string(tmp);
list->path = estrndup(str->val, str->len);
zend_string_release(str);
}
- if ((tmp = zend_hash_str_find(ht, ZEND_STRL("domain")))) {
+ if ((tmp = zend_hash_str_find_ind(ht, ZEND_STRL("domain")))) {
zend_string *str = zval_get_string(tmp);
list->domain = estrndup(str->val, str->len);
ce = php_http_cookie_class_entry;
}
- o = ecalloc(sizeof(*o) + sizeof(zval) * (ce->default_properties_count - 1), 1);
+ o = ecalloc(1, sizeof(*o) + zend_object_properties_size(ce));
zend_object_std_init(&o->zo, ce);
object_properties_init(&o->zo, ce);
o->zo.handlers = &php_http_cookie_object_handlers;
memcpy(&php_http_cookie_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
php_http_cookie_object_handlers.offset = XtOffsetOf(php_http_cookie_object_t, zo);
php_http_cookie_object_handlers.clone_obj = php_http_cookie_object_clone;
- php_http_cookie_object_handlers.dtor_obj = php_http_cookie_object_free;
+ php_http_cookie_object_handlers.free_obj = php_http_cookie_object_free;
zend_declare_class_constant_long(php_http_cookie_class_entry, ZEND_STRL("PARSE_RAW"), PHP_HTTP_COOKIE_PARSE_RAW TSRMLS_CC);
zend_declare_class_constant_long(php_http_cookie_class_entry, ZEND_STRL("SECURE"), PHP_HTTP_COOKIE_SECURE TSRMLS_CC);