summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonardo Taccari <iamleot@gmail.com>2018-12-12 16:05:45 +0100
committerDaniel Stenberg <daniel@haxx.se>2018-12-13 10:21:33 +0100
commit305d25ed8a18bbe1fa59c4ec735de6a05ef27f45 (patch)
tree98c194527c74481233afa99f94fd8e53deffc32e
parenta58b27740fd78fee88b35104fa71b7019280ccff (diff)
downloadcurl-305d25ed8a18bbe1fa59c4ec735de6a05ef27f45.tar.gz
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
-rw-r--r--lib/urlapi.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/urlapi.c b/lib/urlapi.c
index e68748818..6919ff1bd 100644
--- a/lib/urlapi.c
+++ b/lib/urlapi.c
@@ -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 : "");
}