mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +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--;
|
||||
if (d == path
|
||||
&& 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] == '/');
|
||||
continue;
|
||||
}
|
||||
|
@ -804,12 +811,16 @@ QFS_CompressPath (const char *pth)
|
|||
p++;
|
||||
if (*p == '/') {
|
||||
p++;
|
||||
// skip over multiple / (foo//bar -> foo/bar)
|
||||
for (d = p; *d == '/'; d++)
|
||||
;
|
||||
if (d != p)
|
||||
strcpy (p, d);
|
||||
}
|
||||
}
|
||||
// strip any trailing /, but not if it's the root /
|
||||
if (--p != path && *p == '/')
|
||||
*p = 0;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ struct {
|
|||
{"/..", "/"},
|
||||
{"foo/..", ""},
|
||||
{"foo/bar/..", "foo"},
|
||||
{"foo//bar", "foo/bar"},
|
||||
{"../foo/..", ".."},
|
||||
{"\\blah\\../foo/..\\baz/.\\x", "/baz/x"},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue