urlapi: distinguish possibly empty query

If just a `?' to indicate the query is passed always store a zero length
query instead of having a NULL query.

This permits to distinguish URL with trailing `?'.

Fixes #3369
Closes #3370
This commit is contained in:
Leonardo Taccari 2018-12-12 16:05:45 +01:00 committed by Daniel Stenberg
parent a58b27740f
commit 305d25ed8a
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
1 changed files with 3 additions and 3 deletions

View File

@ -864,7 +864,7 @@ static CURLUcode seturl(const char *url, CURLU *u, unsigned int flags)
return CURLUE_OUT_OF_MEMORY;
}
if(query && query[0]) {
if(query) {
u->query = strdup(query);
if(!u->query)
return CURLUE_OUT_OF_MEMORY;
@ -1071,8 +1071,8 @@ CURLUcode curl_url_get(CURLU *u, CURLUPart what,
port ? port : "",
(u->path && (u->path[0] != '/')) ? "/": "",
u->path ? u->path : "/",
u->query? "?": "",
u->query? u->query : "",
(u->query && u->query[0]) ? "?": "",
(u->query && u->query[0]) ? u->query : "",
u->fragment? "#": "",
u->fragment? u->fragment : "");
}