diff options
author | Zenju <zenju@gmx.de> | 2019-09-13 17:32:04 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2019-09-18 09:27:21 +0200 |
commit | 1c02a4e8747defab6607e90173d294875eb73ba1 (patch) | |
tree | 8b7e8edeea6989945f3ddafc13373e369a5f6b56 /lib | |
parent | ac58c51b297466e248c2c1201c2c6c895c477a11 (diff) |
FTP: remove trailing slash from path for LIST/MLSD
Closes #4348
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ftp.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -1446,20 +1446,19 @@ static CURLcode ftp_state_list(struct connectdata *conn) The other ftp_filemethods will CWD into dir/dir/ first and then just do LIST (in that case: nothing to do here) */ - char *cmd, *lstArg, *slashPos; + char *cmd, *lstArg; const char *inpath = ftp->path; lstArg = NULL; if((data->set.ftp_filemethod == FTPFILE_NOCWD) && inpath && inpath[0] && strchr(inpath, '/')) { - size_t n = strlen(inpath); + /* chop off the file part if format is dir/file + otherwise remove the trailing slash for dir/dir/ + and full paths like %2f/ except for / */ + size_t n = strrchr(inpath, '/') - inpath; + if(n == 0) + ++n; - /* Check if path does not end with /, as then we cut off the file part */ - if(inpath[n - 1] != '/') { - /* chop off the file part if format is dir/dir/file */ - slashPos = strrchr(inpath, '/'); - n = slashPos - inpath; - } result = Curl_urldecode(data, inpath, n, &lstArg, NULL, TRUE); if(result) return result; |