Merge pull request #1395 from LORgames/ssurtees/normalizeFix

Fixed edge case in path.normalize
This commit is contained in:
Samuel Surtees 2020-02-04 22:45:01 +10:00 committed by GitHub
commit a640f86d5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -181,8 +181,7 @@ int path_normalize(lua_State* L)
// path is surrounded with quotes // path is surrounded with quotes
if (readPtr != endPtr && if (readPtr != endPtr &&
IS_QUOTE(*readPtr) && IS_QUOTE(endPtr[-1]) && IS_QUOTE(*readPtr))
*readPtr == endPtr[-1])
{ {
*(writePtr++) = *(readPtr++); *(writePtr++) = *(readPtr++);
} }

View File

@ -740,3 +740,19 @@
-- End -- End
test.isequal("../../test/${MYVAR}", path.normalize("../../test/${MYVAR}")) test.isequal("../../test/${MYVAR}", path.normalize("../../test/${MYVAR}"))
end end
function suite.normalize_quotedpath_withTokens()
-- Premake tokens
test.isequal("\"%{wks.location}../../test\"", path.normalize("\"%{wks.location}../../test\""))
-- Visual Studio var
test.isequal("\"$(SolutionDir)../../test\"", path.normalize("\"$(SolutionDir)../../test\""))
-- Windows env var
test.isequal("\"%APPDATA%../../test\"", path.normalize("\"%APPDATA%../../test\""))
-- Unix env var
test.isequal("\"${HOME}../../test\"", path.normalize("\"${HOME}../../test\""))
-- Middle
test.isequal("\"../../${MYVAR}/../test\"", path.normalize("\"../../${MYVAR}/../test\""))
-- End
test.isequal("\"../../test/${MYVAR}\"", path.normalize("\"../../test/${MYVAR}\""))
end