mirror of
https://github.com/moparisthebest/curl
synced 2024-12-23 16:48:49 -05: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 "progress.h"
|
||||||
#include "gopher.h"
|
#include "gopher.h"
|
||||||
#include "select.h"
|
#include "select.h"
|
||||||
|
#include "strdup.h"
|
||||||
#include "url.h"
|
#include "url.h"
|
||||||
#include "escape.h"
|
#include "escape.h"
|
||||||
#include "warnless.h"
|
#include "warnless.h"
|
||||||
|
#include "curl_printf.h"
|
||||||
#include "curl_memory.h"
|
#include "curl_memory.h"
|
||||||
/* The last #include file should be: */
|
/* The last #include file should be: */
|
||||||
#include "memdebug.h"
|
#include "memdebug.h"
|
||||||
@ -78,7 +80,9 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
|
|||||||
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
|
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
|
||||||
|
|
||||||
curl_off_t *bytecount = &data->req.bytecount;
|
curl_off_t *bytecount = &data->req.bytecount;
|
||||||
|
char *gopherpath;
|
||||||
char *path = data->state.up.path;
|
char *path = data->state.up.path;
|
||||||
|
char *query = data->state.up.query;
|
||||||
char *sel = NULL;
|
char *sel = NULL;
|
||||||
char *sel_org = NULL;
|
char *sel_org = NULL;
|
||||||
ssize_t amount, k;
|
ssize_t amount, k;
|
||||||
@ -86,8 +90,16 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
|
|||||||
|
|
||||||
*done = TRUE; /* unconditionally */
|
*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 "" */
|
/* Create selector. Degenerate cases: / and /1 => convert to "" */
|
||||||
if(strlen(path) <= 2) {
|
if(strlen(gopherpath) <= 2) {
|
||||||
sel = (char *)"";
|
sel = (char *)"";
|
||||||
len = strlen(sel);
|
len = strlen(sel);
|
||||||
}
|
}
|
||||||
@ -95,11 +107,12 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
|
|||||||
char *newp;
|
char *newp;
|
||||||
|
|
||||||
/* Otherwise, drop / and the first character (i.e., item type) ... */
|
/* Otherwise, drop / and the first character (i.e., item type) ... */
|
||||||
newp = path;
|
newp = gopherpath;
|
||||||
newp += 2;
|
newp += 2;
|
||||||
|
|
||||||
/* ... and finally unescape */
|
/* ... and finally unescape */
|
||||||
result = Curl_urldecode(data, newp, 0, &sel, &len, FALSE);
|
result = Curl_urldecode(data, newp, 0, &sel, &len, FALSE);
|
||||||
|
free(gopherpath);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
sel_org = sel;
|
sel_org = sel;
|
||||||
|
Loading…
Reference in New Issue
Block a user