mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 00:24:12 +00:00
Fix some path compression bugs.
This commit is contained in:
parent
550b094b93
commit
f1943ebaab
2 changed files with 13 additions and 1 deletions
|
@ -785,7 +785,14 @@ QFS_CompressPath (const char *pth)
|
||||||
d--;
|
d--;
|
||||||
if (d == path
|
if (d == path
|
||||||
&& d[0] == '.' && d[1] == '.'
|
&& d[0] == '.' && d[1] == '.'
|
||||||
&& (d[2] == '/' || d[2] == '0')) {
|
&& (d[2] == '/' || d[2] == '\0')) {
|
||||||
|
p += 2 + (p[2] == '/');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (d[0] == '/'
|
||||||
|
&& d[1] == '.' && d[2] == '.'
|
||||||
|
&& (d[3] == '/' || d[3] == '\0')) {
|
||||||
|
*p = 0;
|
||||||
p += 2 + (p[2] == '/');
|
p += 2 + (p[2] == '/');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -804,12 +811,16 @@ QFS_CompressPath (const char *pth)
|
||||||
p++;
|
p++;
|
||||||
if (*p == '/') {
|
if (*p == '/') {
|
||||||
p++;
|
p++;
|
||||||
|
// skip over multiple / (foo//bar -> foo/bar)
|
||||||
for (d = p; *d == '/'; d++)
|
for (d = p; *d == '/'; d++)
|
||||||
;
|
;
|
||||||
if (d != p)
|
if (d != p)
|
||||||
strcpy (p, d);
|
strcpy (p, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// strip any trailing /, but not if it's the root /
|
||||||
|
if (--p != path && *p == '/')
|
||||||
|
*p = 0;
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ struct {
|
||||||
{"/..", "/"},
|
{"/..", "/"},
|
||||||
{"foo/..", ""},
|
{"foo/..", ""},
|
||||||
{"foo/bar/..", "foo"},
|
{"foo/bar/..", "foo"},
|
||||||
|
{"foo//bar", "foo/bar"},
|
||||||
{"../foo/..", ".."},
|
{"../foo/..", ".."},
|
||||||
{"\\blah\\../foo/..\\baz/.\\x", "/baz/x"},
|
{"\\blah\\../foo/..\\baz/.\\x", "/baz/x"},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue