diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ftp.c | 17 | 
1 files changed, 15 insertions, 2 deletions
| @@ -4316,13 +4316,17 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)      }      slash_pos=strrchr(cur_pos, '/');      if(slash_pos || !*cur_pos) { +      size_t dirlen = slash_pos-cur_pos; +        ftpc->dirs = calloc(1, sizeof(ftpc->dirs[0]));        if(!ftpc->dirs)          return CURLE_OUT_OF_MEMORY; +      if(!dirlen) +        dirlen++; +        ftpc->dirs[0] = curl_easy_unescape(conn->data, slash_pos ? cur_pos : "/", -                                         slash_pos ? -                                         curlx_sztosi(slash_pos-cur_pos) : 1, +                                         slash_pos ? curlx_sztosi(dirlen) : 1,                                           NULL);        if(!ftpc->dirs[0]) {          freedirs(ftpc); @@ -4377,6 +4381,15 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)          }          else {            cur_pos = slash_pos + 1; /* jump to the rest of the string */ +          if(!ftpc->dirdepth) { +            /* path starts with a slash, add that as a directory */ +            ftpc->dirs[ftpc->dirdepth] = strdup("/"); +            if(!ftpc->dirs[ftpc->dirdepth++]) { /* run out of memory ... */ +              failf(data, "no memory"); +              freedirs(ftpc); +              return CURLE_OUT_OF_MEMORY; +            } +          }            continue;          } | 
