X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_cookie.c;h=ff67b1c1d2c6ed2a189f2e18647b9db196ac53b2;hp=a04de835a1ea1a0da2e3817305e4464742e5fe11;hb=0347914eda73287d017c6512dfe870382312299a;hpb=03f11ce599fa5a89148d588caf6ccec7f939e9d4 diff --git a/php_http_cookie.c b/php_http_cookie.c index a04de83..ff67b1c 100644 --- a/php_http_cookie.c +++ b/php_http_cookie.c @@ -113,27 +113,26 @@ void php_http_cookie_list_add_extra(php_http_cookie_list_t *list, const char *na #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") { @@ -148,7 +147,7 @@ static void add_entry(php_http_cookie_list_t *list, char **allowed_extras, long 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; } @@ -156,13 +155,13 @@ static void add_entry(php_http_cookie_list_t *list, char **allowed_extras, long } /* 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) @@ -188,9 +187,11 @@ php_http_cookie_list_t *php_http_cookie_list_parse(php_http_cookie_list_t *list, 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(); } } } @@ -234,16 +235,16 @@ php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_cookie_list_t 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 { @@ -259,7 +260,7 @@ php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_cookie_list_t 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 { @@ -273,13 +274,13 @@ php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_cookie_list_t 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); @@ -381,7 +382,7 @@ php_http_cookie_object_t *php_http_cookie_object_new_ex(zend_class_entry *ce, ph 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; @@ -1021,7 +1022,7 @@ PHP_MINIT_FUNCTION(http_cookie) 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);