1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] Correctly merge DOS-like absolute directories.

Published in <sxslmbomnm7.fsf@florida.arsdigita.de>.
This commit is contained in:
hniksic 2002-04-15 18:36:16 -07:00
parent 426bf23ae1
commit 7953158bce
2 changed files with 28 additions and 7 deletions

View File

@ -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>
* http.c (gethttp): If Content-Type is not given, assume

View File

@ -383,17 +383,31 @@ Error in server response, closing control connection.\n"));
/* Change working directory. To change to a non-absolute
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);
char *ntarget = (char *)alloca (idlen + 1 + strlen (u->dir) + 1);
/* idlen == 1 means con->id = "/" */
sprintf (ntarget, "%s%s%s", con->id, idlen == 1 ? "" : "/",
target);
char *ntarget, *p;
/* Strip trailing slash(es) from con->id. */
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 ((" old: '%s'\n new: '%s'\n", target, ntarget));
DEBUGP ((" pwd: '%s'\n old: '%s'\n new: '%s'\n",
con->id, target, ntarget));
target = ntarget;
}