written = php_stream_write(s, buf, len);
if (written != len) {
- php_error_docref(NULL, E_WARNING, "Failed to append %zu bytes to body; wrote %zu", len, written);
+ php_error_docref(NULL, E_WARNING, "Failed to append %zu bytes to body; wrote %zu", len, written == (size_t) -1 ? 0 : written);
}
return len;
ZEND_RESULT_CODE php_http_message_body_add_form_field(php_http_message_body_t *body, const char *name, const char *value_str, size_t value_len)
{
- zend_string *safe_name = zend_string_init(name, strlen(name), 0);
+ zend_string *safe_name, *zstr_name = zend_string_init(name, strlen(name), 0);
- safe_name = php_addslashes(safe_name, 1);
+#if PHP_VERSION_ID < 70300
+ safe_name = php_addslashes(zstr_name, 1);
+#else
+ safe_name = php_addslashes(zstr_name);
+ zend_string_release_ex(zstr_name, 0);
+#endif
BOUNDARY_OPEN(body);
php_http_message_body_appendf(
{
size_t path_len = strlen(path);
char *path_dup = estrndup(path, path_len);
- zend_string *base_name, *safe_name = zend_string_init(name, strlen(name), 0);
-
- safe_name = php_addslashes(safe_name, 1);
+ zend_string *base_name, *safe_name, *zstr_name = zend_string_init(name, strlen(name), 0);
+
+#if PHP_VERSION_ID < 70300
+ safe_name = php_addslashes(zstr_name, 1);
+#else
+ safe_name = php_addslashes(zstr_name);
+ zend_string_release_ex(zstr_name, 0);
+#endif
base_name = php_basename(path_dup, path_len, NULL, 0);
BOUNDARY_OPEN(body);
} else if (key->key) {
new_key = estrdup(key->key->val);
} else {
- new_key = estrdup("");
+ spprintf(&new_key, 0, "%lu", key->h);
}
return new_key;
ZEND_HASH_FOREACH_KEY_VAL_IND(files, key.h, key.key, val)
{
if (Z_TYPE_P(val) == IS_ARRAY || Z_TYPE_P(val) == IS_OBJECT) {
- char *str = format_key(&key, name);
+ char *str = key.key ? format_key(&key, name) : NULL;
+ const char *prefix = str ? str : name;
- if (SUCCESS != add_recursive_files(body, str, HASH_OF(val))) {
+ if (SUCCESS != add_recursive_files(body, prefix, HASH_OF(val))) {
efree(str);
HT_UNPROTECT_RECURSION(files);
return FAILURE;
}
- efree(str);
+ if (str) {
+ efree(str);
+ }
}
}
ZEND_HASH_FOREACH_END();
return FAILURE;
} else {
zend_string *znc = zval_get_string(zname), *ztc = zval_get_string(ztype);
- php_http_arrkey_t arrkey = {0, znc};
+ php_http_arrkey_t arrkey = {0, znc, 0, 0};
char *key = format_key(&arrkey, name);
ZEND_RESULT_CODE ret = php_http_message_body_add_form_file(body, key, ztc->val, zfc->val, stream);
return o;
}
-zend_object *php_http_message_body_object_clone(zval *object)
+zend_object *php_http_message_body_object_clone(zend_object *object)
{
php_http_message_body_object_t *new_obj;
- php_http_message_body_object_t *old_obj = PHP_HTTP_OBJ(NULL, object);
+ php_http_message_body_object_t *old_obj = PHP_HTTP_OBJ(object, NULL);
php_http_message_body_t *body = php_http_message_body_copy(old_obj->body, NULL);
new_obj = php_http_message_body_object_new_ex(old_obj->zo.ce, body);
return &new_obj->zo;
}
-static HashTable *php_http_message_body_object_get_gc(zval *object, zval **table, int *n)
+static HashTable *php_http_message_body_object_get_gc(zend_object *object, zval **table, int *n)
{
- php_http_message_body_object_t *obj = PHP_HTTP_OBJ(NULL, object);
- HashTable *props = Z_OBJPROP_P(object);
+ php_http_message_body_object_t *obj = PHP_HTTP_OBJ(object, NULL);
+ HashTable *props = object->handlers->get_properties(object);
uint32_t count = zend_hash_num_elements(props);
obj->gc = erealloc(obj->gc, (1 + count) * sizeof(zval));
}
static zend_function_entry php_http_message_body_methods[] = {
- PHP_ME(HttpMessageBody, __construct, ai_HttpMessageBody___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
+ PHP_ME(HttpMessageBody, __construct, ai_HttpMessageBody___construct, ZEND_ACC_PUBLIC)
PHP_ME(HttpMessageBody, __toString, ai_HttpMessageBody___toString, ZEND_ACC_PUBLIC)
PHP_MALIAS(HttpMessageBody, toString, __toString, ai_HttpMessageBody___toString, ZEND_ACC_PUBLIC)
PHP_MALIAS(HttpMessageBody, serialize, __toString, ai_HttpMessageBody___toString, ZEND_ACC_PUBLIC)