mirror of
https://github.com/curl/curl.git
synced 2024-11-27 05:50:21 +08:00
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
This commit is contained in:
parent
305d25ed8a
commit
9026083ddb
17
lib/gopher.c
17
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;
|
||||
|
Loading…
Reference in New Issue
Block a user