summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/gopher.c
diff options
context:
space:
mode:
authordartraiden <wowemuh@gmail.com>2019-02-10 02:02:38 +0300
committerdartraiden <wowemuh@gmail.com>2019-02-10 02:06:58 +0300
commiteee2c11f79a8958e65cc485af1e7afcbd394db1e (patch)
tree9ab4418393997629ef9dc7ae78089cbece595d0c /libs/libcurl/src/gopher.c
parent33d2c8e71902aa37d3fc978cb91e0a842a600960 (diff)
libcurl: update to 7.64
Diffstat (limited to 'libs/libcurl/src/gopher.c')
-rw-r--r--libs/libcurl/src/gopher.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/libs/libcurl/src/gopher.c b/libs/libcurl/src/gopher.c
index b441a641d9..485b4b79a0 100644
--- a/libs/libcurl/src/gopher.c
+++ b/libs/libcurl/src/gopher.c
@@ -31,9 +31,11 @@
#include "progress.h"
#include "gopher.h"
#include "select.h"
+#include "strdup.h"
#include "url.h"
#include "escape.h"
#include "warnless.h"
+#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
@@ -78,7 +80,9 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
curl_off_t *bytecount = &data->req.bytecount;
+ char *gopherpath;
char *path = data->state.up.path;
+ char *query = data->state.up.query;
char *sel = NULL;
char *sel_org = NULL;
ssize_t amount, k;
@@ -86,20 +90,30 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
*done = TRUE; /* unconditionally */
+ if(path && query)
+ gopherpath = aprintf("%s?%s", path, query);
+ else
+ gopherpath = strdup(path);
+
+ if(!gopherpath)
+ return CURLE_OUT_OF_MEMORY;
+
/* Create selector. Degenerate cases: / and /1 => convert to "" */
- if(strlen(path) <= 2) {
+ if(strlen(gopherpath) <= 2) {
sel = (char *)"";
len = strlen(sel);
+ free(gopherpath);
}
else {
char *newp;
/* Otherwise, drop / and the first character (i.e., item type) ... */
- newp = path;
+ newp = gopherpath;
newp += 2;
/* ... and finally unescape */
result = Curl_urldecode(data, newp, 0, &sel, &len, FALSE);
+ free(gopherpath);
if(result)
return result;
sel_org = sel;