Merge pull request #31 from starkos/path-normalize-fix
Fix handling of "../../.." sequences in path.normalize()
This commit is contained in:
commit
de47325370
@ -35,13 +35,11 @@ int path_normalize(lua_State* L)
|
||||
if (ch == '.' && last == '.') {
|
||||
ptr = dst - 3;
|
||||
while (ptr >= buffer) {
|
||||
if (*ptr != '/') {
|
||||
--ptr;
|
||||
}
|
||||
else {
|
||||
if (ptr[0] == '/' && ptr[1] != '.' && ptr[2] != '.') {
|
||||
dst = ptr;
|
||||
break;
|
||||
}
|
||||
--ptr;
|
||||
}
|
||||
if (ptr >= buffer) {
|
||||
++src;
|
||||
|
@ -385,6 +385,21 @@
|
||||
test.isequal("../../test", p)
|
||||
end
|
||||
|
||||
function suite.normalize_Test4()
|
||||
local p = path.normalize("../../../test/*.h")
|
||||
test.isequal("../../../test/*.h", p)
|
||||
end
|
||||
|
||||
function suite.normalize_trailingDots1()
|
||||
local p = path.normalize("../game/test/..")
|
||||
test.isequal("../game", p)
|
||||
end
|
||||
|
||||
function suite.normalize_trailingDots2()
|
||||
local p = path.normalize("../game/..")
|
||||
test.isequal("..", p)
|
||||
end
|
||||
|
||||
function suite.normalize()
|
||||
test.isequal("d:/ProjectB/bin", path.normalize("d:/ProjectA/../ProjectB/bin"))
|
||||
test.isequal("/ProjectB/bin", path.normalize("/ProjectA/../ProjectB/bin"))
|
||||
|
Loading…
Reference in New Issue
Block a user