curl-users
Re: relative path with ftp using curl
Date: 24 Jul 2003 18:55:04 +0200
fpons_at_mandrakesoft.com (François Pons) writes:
> David Seaman <dseaman_at_luminet.net> writes:
>
> > François,
> > Try "ftp//user:pass/%2fdir". (The server will url-decode the %2f as a /)
>
> Yes, thanks, it works.
>
> But other tools allows a double // at the beginning to be interpreted as an
> absolute directory ?
Finaly the following patch seems to be acceptable maybe ? :
--- curl-7.10.6-pre4/lib/ftp.c.fpons 2003-07-20 02:18:11.000000000 +0200
+++ curl-7.10.6-pre4/lib/ftp.c 2003-07-24 18:43:56.000000000 +0200
@@ -2134,12 +2134,15 @@
/* parse the URL path into separate path components */
while((slash_pos=strchr(cur_pos, '/'))) {
+ /* 1 or 0 to indicate absolute directory */
+ int absolute_dir = cur_pos - conn->ppath > 0 && path_part == 0;
/* seek out the next path component */
if (slash_pos-cur_pos) {
/* we skip empty path components, like "x//y" since the FTP command CWD
requires a parameter and a non-existant parameter a) doesn't work on
many servers and b) has no effect on the others. */
- ftp->dirs[path_part] = curl_unescape(cur_pos,slash_pos-cur_pos);
+ ftp->dirs[path_part] = curl_unescape(cur_pos-absolute_dir,
+ slash_pos-cur_pos+absolute_dir);
if (!ftp->dirs[path_part]) { /* run out of memory ... */
failf(data, "no memory");
--- curl-7.10.6-pre4/tests/data/test106.fpons 2003-07-24 18:43:23.000000000 +0200
+++ curl-7.10.6-pre4/tests/data/test106 2003-07-24 18:42:50.000000000 +0200
@@ -19,7 +19,7 @@
FTP GET with type=A style ASCII URL using %20 codes
</name>
<command>
-"ftp://%HOSTIP:%FTPPORT//path%20with%20%20spaces/and%20things2/106;type=A"
+"ftp://%HOSTIP:%FTPPORT/path%20with%20%20spaces//and%20things2/106;type=A"
</command>
</test>
François.
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
Received on 2003-07-24