fixed a crash when a token contains non-escaped backslashes, and added a unit test

This commit is contained in:
Damien Courtois 2015-06-15 18:15:03 +02:00
parent 701c5a8c65
commit f5d7ef1a5b
2 changed files with 12 additions and 1 deletions

View File

@ -139,7 +139,8 @@
end
return value
else
return expandvalue(value)
-- escape backslashes: they will break loadstring
return expandvalue(value:gsub("\\", "\\\\"))
end
end

View File

@ -119,3 +119,13 @@
x = detoken.expand(os.getcwd() .. "/%{cfg.objdir}/file", environ, {paths=true,pathVars=true})
test.isequal("$(IntDir)/file", x)
end
--
-- Escapes backslashes correctly.
--
function suite.escapesBackslashes()
environ.foo = "some/path"
x = detoken.expand("%{foo:gsub('/', '\\')}", environ)
test.isequal("some\\path", x)
end