aboutsummaryrefslogtreecommitdiff
path: root/lib/ftp.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2017-10-10 12:02:11 +0200
committerDaniel Stenberg <daniel@haxx.se>2017-10-10 15:02:38 +0200
commitecf21c551fa3426579463abe34b623111b8d487c (patch)
tree3614f0ab7feba13a126d506e6814253de6f2068c /lib/ftp.c
parent00fb811e2b05ed88d4847c0a96a7dddb51e77bcf (diff)
FTP: URL decode path for dir listing in nocwd mode
Reported-by: Zenju on github Test 244 added to verify Fixes #1974 Closes #1976
Diffstat (limited to 'lib/ftp.c')
-rw-r--r--lib/ftp.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index d7be88136..0c9df7890 100644
--- a/lib/ftp.c
+++ b/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",