fix for path.join problem when both string start with a "..", a unit test has been added

This commit is contained in:
Lusito 2015-08-01 21:10:02 +02:00
parent 6058243aa1
commit 15ceabac48
2 changed files with 8 additions and 0 deletions

View File

@ -71,6 +71,10 @@ int path_join(lua_State* L)
break;
}
if (start[0] == '.' && start[1] == '.' && start[2] == '\0'){
break;
}
/* otherwise trim segment and the ".." sequence */
if (start != buffer) {
--start;

View File

@ -267,6 +267,10 @@
test.isequal("", path.join("p1/p2/", "../.."))
end
function suite.join_OnBothUpTwoFolders()
test.isequal("../../../../foo", path.join("../../", "../../foo"))
end
function suite.join_OnUptwoFolders()
test.isequal("p1/foo", path.join("p1/p2/p3", "../../foo"))
end