Fixed a bug with normalizing paths that contain dot folders
- Added additional tests
This commit is contained in:
parent
ef9b341d6f
commit
9039232548
@ -35,7 +35,8 @@ static void* normalize_substring(const char* str, const char* endPtr, char* writ
|
|||||||
|
|
||||||
ptr = writePtr - 3;
|
ptr = writePtr - 3;
|
||||||
while (ptr >= writeBegin) {
|
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;
|
writePtr -= writePtr - ptr;
|
||||||
|
|
||||||
/* special fix for cases, when '..' is the last chars in path i.e. d:\game\.., this should be converted into d:\,
|
/* 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()
|
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/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
|
end
|
||||||
|
Reference in New Issue
Block a user