diff options
author | Leonardo Taccari <iamleot@gmail.com> | 2018-12-12 16:58:18 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-12-13 10:22:25 +0100 |
commit | 9026083ddb2a986f41cfc9337640eadd2dc372ea (patch) | |
tree | c151e6f0397c46d425996b33b9b72907eb7a75c6 /lib | |
parent | 305d25ed8a18bbe1fa59c4ec735de6a05ef27f45 (diff) |
gopher: always include the entire gopher-path in request
After the migration to URL API all octets in the selector after the
first `?' were interpreted as query and accidentally discarded and not
passed to the server.
Add a gopherpath to always concatenate possible path and query URL
pieces.
Fixes #3369
Closes #3370
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gopher.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/gopher.c b/lib/gopher.c index b441a641d..151bac1ad 100644 --- a/lib/gopher.c +++ b/lib/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,8 +90,16 @@ 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); } @@ -95,11 +107,12 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done) 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; |