]> granicus.if.org Git - curl/commitdiff
urlapi: distinguish possibly empty query
authorLeonardo Taccari <iamleot@gmail.com>
Wed, 12 Dec 2018 15:05:45 +0000 (16:05 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 13 Dec 2018 09:21:33 +0000 (10:21 +0100)
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

lib/urlapi.c

index e68748818c7f232be95ef0f7578da697acad2076..6919ff1bd7edb1f24bfd70f79062936692abedf5 100644 (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 : "");
     }