mirror of
https://github.com/mirror/wget.git
synced 2025-01-23 10:40:40 +08:00
[svn] Correctly merge DOS-like absolute directories.
Published in <sxslmbomnm7.fsf@florida.arsdigita.de>.
This commit is contained in:
parent
426bf23ae1
commit
7953158bce
@ -1,3 +1,10 @@
|
|||||||
|
2002-04-16 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
|
* ftp.c (getftp): Treat directories that begin with <letter>: as
|
||||||
|
absolute.
|
||||||
|
(getftp): Strip trailing slashes from con->id before merging it
|
||||||
|
with TARGET.
|
||||||
|
|
||||||
2002-04-16 Hrvoje Niksic <hniksic@arsdigita.com>
|
2002-04-16 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
* http.c (gethttp): If Content-Type is not given, assume
|
* http.c (gethttp): If Content-Type is not given, assume
|
||||||
|
28
src/ftp.c
28
src/ftp.c
@ -383,17 +383,31 @@ Error in server response, closing control connection.\n"));
|
|||||||
|
|
||||||
/* Change working directory. To change to a non-absolute
|
/* Change working directory. To change to a non-absolute
|
||||||
Unix directory, we need to prepend initial directory
|
Unix directory, we need to prepend initial directory
|
||||||
(con->id) to it. Absolute directories "just work". */
|
(con->id) to it. Absolute directories "just work".
|
||||||
|
|
||||||
if (*target != '/')
|
A relative directory is one that does not begin with '/'
|
||||||
|
and, on non-Unix OS'es, one that doesn't begin with
|
||||||
|
"<letter>:". */
|
||||||
|
|
||||||
|
if (target[0] != '/'
|
||||||
|
&& !(con->rs != ST_UNIX
|
||||||
|
&& ISALPHA (target[0]) && target[1] == ':'))
|
||||||
{
|
{
|
||||||
int idlen = strlen (con->id);
|
int idlen = strlen (con->id);
|
||||||
char *ntarget = (char *)alloca (idlen + 1 + strlen (u->dir) + 1);
|
char *ntarget, *p;
|
||||||
/* idlen == 1 means con->id = "/" */
|
|
||||||
sprintf (ntarget, "%s%s%s", con->id, idlen == 1 ? "" : "/",
|
/* Strip trailing slash(es) from con->id. */
|
||||||
target);
|
while (idlen > 0 && con->id[idlen - 1] == '/')
|
||||||
|
--idlen;
|
||||||
|
p = ntarget = (char *)alloca (idlen + 1 + strlen (u->dir) + 1);
|
||||||
|
memcpy (p, con->id, idlen);
|
||||||
|
p += idlen;
|
||||||
|
*p++ = '/';
|
||||||
|
strcpy (p, target);
|
||||||
|
|
||||||
DEBUGP (("Prepended initial PWD to relative path:\n"));
|
DEBUGP (("Prepended initial PWD to relative path:\n"));
|
||||||
DEBUGP ((" old: '%s'\n new: '%s'\n", target, ntarget));
|
DEBUGP ((" pwd: '%s'\n old: '%s'\n new: '%s'\n",
|
||||||
|
con->id, target, ntarget));
|
||||||
target = ntarget;
|
target = ntarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user