X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_url_api.c;fp=http_url_api.c;h=1ccd4dba72a529f92929d8016bc735a63d3d0051;hp=bdda91161088340f01a72cf38738f41eae50d5db;hb=24d2d35cd00eca44a97a6b11340c2790421216fa;hpb=5e4f91f90fd9374f5bdf714de2d08d3c143b9bd4 diff --git a/http_url_api.c b/http_url_api.c index bdda911..1ccd4db 100644 --- a/http_url_api.c +++ b/http_url_api.c @@ -21,6 +21,7 @@ #include "ext/standard/php_string.h" #include "php_http_api.h" +#include "php_http_querystring_api.h" #include "php_http_url_api.h" static inline char *localhostname(void) @@ -131,10 +132,21 @@ PHP_HTTP_API void _http_build_url(int flags, const php_url *old_url, const php_u } if (!(flags & HTTP_URL_STRIP_QUERY)) { if ((flags & HTTP_URL_JOIN_QUERY) && __URLSET(new_url, query) && __URLSET(old_url, query)) { - url->query = ecalloc(1, strlen(new_url->query) + strlen(old_url->query) + 1 + 1); - strcat(url->query, old_url->query); - strcat(url->query, "&"); - strcat(url->query, new_url->query); + zval qarr, qstr; + + INIT_PZVAL(&qstr); + INIT_PZVAL(&qarr); + array_init(&qarr); + + ZVAL_STRING(&qstr, old_url->query, 0); + http_querystring_modify(&qarr, &qstr); + ZVAL_STRING(&qstr, new_url->query, 0); + http_querystring_modify(&qarr, &qstr); + + ZVAL_NULL(&qstr); + http_querystring_update(&qarr, &qstr); + url->query = Z_STRVAL(qstr); + zval_dtor(&qarr); } else { __URLCPY(query); }