[prev in list] [next in list] [prev in thread] [next in thread]
List: wget
Subject: Re: problem with downloading when HREF has "../"
From: Hrvoje Niksic <hniksic () xemacs ! org>
Date: 2006-02-27 19:44:33
Message-ID: 87k6bg4me6.fsf () xemacs ! org
[Download RAW message or body]
Mauro Tortonesi <mauro.tortonesi@unife.it> writes:
> i am going to test and apply your patch later this week [...]
Here is the change in the form of a patch. It removes all the
unnecessary code, not only the two offending lines, but is in essence
equivalent to the change as originally suggested by Frank.
2006-02-27 Hrvoje Niksic <hniksic@xemacs.org>
* url.c (path_simplify): Don't preserve ".." at beginning of path.
Suggested by Frank McCown.
Index: src/url.c
===================================================================
--- src/url.c (revision 2119)
+++ src/url.c (working copy)
@@ -1511,8 +1511,7 @@
{
char *h = path; /* hare */
char *t = path; /* tortoise */
- char *beg = path; /* boundary for backing the tortoise */
- char *end = path + strlen (path);
+ char *end = strchr (path, '\0');
while (h < end)
{
@@ -1527,26 +1526,17 @@
{
/* Handle "../" by retreating the tortoise by one path
element -- but not past beggining. */
- if (t > beg)
+ if (t > path)
{
/* Move backwards until T hits the beginning of the
previous path element or the beginning of path. */
- for (--t; t > beg && t[-1] != '/'; t--)
+ for (--t; t > path && t[-1] != '/'; t--)
;
}
- else
- {
- /* If we're at the beginning, copy the "../" literally
- move the beginning so a later ".." doesn't remove
- it. */
- beg = t + 3;
- goto regular;
- }
h += 3;
}
else
{
- regular:
/* A regular path element. If H hasn't advanced past T,
simply skip to the next path element. Otherwise, copy
the path element until the next slash. */
@@ -1972,8 +1962,8 @@
{ "", "", false },
{ ".", "", true },
{ "./", "", true },
- { "..", "..", false },
- { "../", "../", false },
+ { "..", "", true },
+ { "../", "", true },
{ "foo", "foo", false },
{ "foo/bar", "foo/bar", false },
{ "foo///bar", "foo///bar", false },
@@ -1986,9 +1976,9 @@
{ "foo/bar/../x", "foo/x", true },
{ "foo/bar/../x/", "foo/x/", true },
{ "foo/..", "", true },
- { "foo/../..", "..", true },
- { "foo/../../..", "../..", true },
- { "foo/../../bar/../../baz", "../../baz", true },
+ { "foo/../..", "", true },
+ { "foo/../../..", "", true },
+ { "foo/../../bar/../../baz", "baz", true },
{ "a/b/../../c", "c", true },
{ "./a/../b", "b", true }
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic