From 9128498bf9b276e2d08ca6902a15430bb431d950 Mon Sep 17 00:00:00 2001 From: Sam Surtees Date: Sun, 2 Feb 2020 16:30:44 +1000 Subject: [PATCH] Fixed edge case in path.normalize --- src/host/path_normalize.c | 3 +-- tests/base/test_path.lua | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/host/path_normalize.c b/src/host/path_normalize.c index a2f0612d..55fcd2ee 100644 --- a/src/host/path_normalize.c +++ b/src/host/path_normalize.c @@ -181,8 +181,7 @@ int path_normalize(lua_State* L) // path is surrounded with quotes if (readPtr != endPtr && - IS_QUOTE(*readPtr) && IS_QUOTE(endPtr[-1]) && - *readPtr == endPtr[-1]) + IS_QUOTE(*readPtr)) { *(writePtr++) = *(readPtr++); } diff --git a/tests/base/test_path.lua b/tests/base/test_path.lua index 387b8321..aac53f50 100755 --- a/tests/base/test_path.lua +++ b/tests/base/test_path.lua @@ -740,3 +740,19 @@ -- End test.isequal("../../test/${MYVAR}", path.normalize("../../test/${MYVAR}")) 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