Merge pull request #988 from LORgames/ssurtees/pathNormalizationFix
Fixed a bug with normalizing paths that contain dot folders
This commit is contained in:
commit
0eda22c602
@ -35,7 +35,8 @@ static void* normalize_substring(const char* str, const char* endPtr, char* writ
|
||||
|
||||
ptr = writePtr - 3;
|
||||
while (ptr >= writeBegin) {
|
||||
if (ptr[0] == '/' && ptr[1] != '.' && ptr[2] != '.') {
|
||||
/* break on '/' except when it's '/../' */
|
||||
if (ptr[0] == '/' && !(ptr[1] == '.' && ptr[2] == '.' && ptr[3] == '/')) {
|
||||
writePtr -= writePtr - ptr;
|
||||
|
||||
/* special fix for cases, when '..' is the last chars in path i.e. d:\game\.., this should be converted into d:\,
|
||||
|
@ -683,4 +683,13 @@
|
||||
function suite.normalize_legitimateDots()
|
||||
test.isequal("d:/test/test..test", path.normalize("d:/test/test..test"))
|
||||
test.isequal("d:/test..test/test", path.normalize("d:/test..test/test"))
|
||||
test.isequal("d:/test/.test", path.normalize("d:/test/.test"))
|
||||
test.isequal("d:/.test", path.normalize("d:/test/../.test"))
|
||||
test.isequal("d:/test", path.normalize("d:/test/.test/.."))
|
||||
test.isequal("d:/test/..test", path.normalize("d:/test/..test"))
|
||||
test.isequal("d:/..test", path.normalize("d:/test/../..test"))
|
||||
test.isequal("d:/test", path.normalize("d:/test/..test/.."))
|
||||
test.isequal("d:/test/.test", path.normalize("d:/test/..test/../.test"))
|
||||
test.isequal("d:/test/..test/.test", path.normalize("d:/test/..test/test/../.test"))
|
||||
test.isequal("d:/test", path.normalize("d:/test/..test/../.test/.."))
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user