- 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);