mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Make sure directory and file names are encoded the same way.
Published in <sxsofgqmf6e.fsf@florida.arsdigita.de>.
This commit is contained in:
parent
08bee01a23
commit
485673c3a8
@ -1,3 +1,10 @@
|
|||||||
|
2002-04-11 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
|
* url.c (url_filename): Use compose_file_name regardless of
|
||||||
|
whether opt.dirstruct is set.
|
||||||
|
(mkstruct): Don't handle the query and the reencoding of DIR; that
|
||||||
|
is done in compose_file_name.
|
||||||
|
|
||||||
2002-04-10 Hrvoje Niksic <hniksic@arsdigita.com>
|
2002-04-10 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
* wget.h: Ditto for extern char *exec_name.
|
* wget.h: Ditto for extern char *exec_name.
|
||||||
|
31
src/url.c
31
src/url.c
@ -1228,9 +1228,8 @@ count_slashes (const char *s)
|
|||||||
static char *
|
static char *
|
||||||
mkstruct (const struct url *u)
|
mkstruct (const struct url *u)
|
||||||
{
|
{
|
||||||
char *dir, *dir_preencoding;
|
char *dir, *file;
|
||||||
char *file, *res, *dirpref;
|
char *res, *dirpref;
|
||||||
char *query = u->query && *u->query ? u->query : NULL;
|
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
if (opt.cut_dirs)
|
if (opt.cut_dirs)
|
||||||
@ -1284,9 +1283,6 @@ mkstruct (const struct url *u)
|
|||||||
dir = newdir;
|
dir = newdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
dir_preencoding = dir;
|
|
||||||
dir = reencode_string (dir_preencoding);
|
|
||||||
|
|
||||||
l = strlen (dir);
|
l = strlen (dir);
|
||||||
if (l && dir[l - 1] == '/')
|
if (l && dir[l - 1] == '/')
|
||||||
dir[l - 1] = '\0';
|
dir[l - 1] = '\0';
|
||||||
@ -1298,16 +1294,9 @@ mkstruct (const struct url *u)
|
|||||||
|
|
||||||
/* Finally, construct the full name. */
|
/* Finally, construct the full name. */
|
||||||
res = (char *)xmalloc (strlen (dir) + 1 + strlen (file)
|
res = (char *)xmalloc (strlen (dir) + 1 + strlen (file)
|
||||||
+ (query ? (1 + strlen (query)) : 0)
|
|
||||||
+ 1);
|
+ 1);
|
||||||
sprintf (res, "%s%s%s", dir, *dir ? "/" : "", file);
|
sprintf (res, "%s%s%s", dir, *dir ? "/" : "", file);
|
||||||
if (query)
|
|
||||||
{
|
|
||||||
strcat (res, "?");
|
|
||||||
strcat (res, query);
|
|
||||||
}
|
|
||||||
if (dir != dir_preencoding)
|
|
||||||
xfree (dir);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1374,26 +1363,25 @@ char *
|
|||||||
url_filename (const struct url *u)
|
url_filename (const struct url *u)
|
||||||
{
|
{
|
||||||
char *file, *name;
|
char *file, *name;
|
||||||
int have_prefix = 0; /* whether we must prepend opt.dir_prefix */
|
|
||||||
|
char *query = u->query && *u->query ? u->query : NULL;
|
||||||
|
|
||||||
if (opt.dirstruct)
|
if (opt.dirstruct)
|
||||||
{
|
{
|
||||||
file = mkstruct (u);
|
char *base = mkstruct (u);
|
||||||
have_prefix = 1;
|
file = compose_file_name (base, query);
|
||||||
|
xfree (base);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *base = *u->file ? u->file : "index.html";
|
char *base = *u->file ? u->file : "index.html";
|
||||||
char *query = u->query && *u->query ? u->query : NULL;
|
|
||||||
file = compose_file_name (base, query);
|
file = compose_file_name (base, query);
|
||||||
}
|
|
||||||
|
|
||||||
if (!have_prefix)
|
|
||||||
{
|
|
||||||
/* Check whether the prefix directory is something other than "."
|
/* Check whether the prefix directory is something other than "."
|
||||||
before prepending it. */
|
before prepending it. */
|
||||||
if (!DOTP (opt.dir_prefix))
|
if (!DOTP (opt.dir_prefix))
|
||||||
{
|
{
|
||||||
|
/* #### should just realloc FILE and prepend dir_prefix. */
|
||||||
char *nfile = (char *)xmalloc (strlen (opt.dir_prefix)
|
char *nfile = (char *)xmalloc (strlen (opt.dir_prefix)
|
||||||
+ 1 + strlen (file) + 1);
|
+ 1 + strlen (file) + 1);
|
||||||
sprintf (nfile, "%s/%s", opt.dir_prefix, file);
|
sprintf (nfile, "%s/%s", opt.dir_prefix, file);
|
||||||
@ -1401,6 +1389,7 @@ url_filename (const struct url *u)
|
|||||||
file = nfile;
|
file = nfile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DOS-ish file systems don't like `%' signs in them; we change it
|
/* DOS-ish file systems don't like `%' signs in them; we change it
|
||||||
to `@'. */
|
to `@'. */
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user