mirror of
https://github.com/curl/curl.git
synced 2026-08-24 15:23:36 +03:00
FTP: URL decode path for dir listing in nocwd mode
Reported-by: Zenju on github Test 244 added to verify Fixes #1974 Closes #1976
This commit is contained in:
parent
00fb811e2b
commit
ecf21c551f
3 changed files with 64 additions and 13 deletions
21
lib/ftp.c
21
lib/ftp.c
|
|
@ -1457,25 +1457,22 @@ static CURLcode ftp_state_list(struct connectdata *conn)
|
|||
then just do LIST (in that case: nothing to do here)
|
||||
*/
|
||||
char *cmd, *lstArg, *slashPos;
|
||||
const char *inpath = data->state.path;
|
||||
|
||||
lstArg = NULL;
|
||||
if((data->set.ftp_filemethod == FTPFILE_NOCWD) &&
|
||||
data->state.path &&
|
||||
data->state.path[0] &&
|
||||
strchr(data->state.path, '/')) {
|
||||
|
||||
lstArg = strdup(data->state.path);
|
||||
if(!lstArg)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
inpath && inpath[0] && strchr(inpath, '/')) {
|
||||
size_t n = strlen(inpath);
|
||||
|
||||
/* Check if path does not end with /, as then we cut off the file part */
|
||||
if(lstArg[strlen(lstArg) - 1] != '/') {
|
||||
|
||||
if(inpath[n - 1] != '/') {
|
||||
/* chop off the file part if format is dir/dir/file */
|
||||
slashPos = strrchr(lstArg, '/');
|
||||
if(slashPos)
|
||||
*(slashPos + 1) = '\0';
|
||||
slashPos = strrchr(inpath, '/');
|
||||
n = slashPos - inpath;
|
||||
}
|
||||
result = Curl_urldecode(data, inpath, n, &lstArg, NULL, FALSE);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
|
||||
cmd = aprintf("%s%s%s",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue