fixed incorrect backslashes escaping outside of tokens
This commit is contained in:
parent
f5d7ef1a5b
commit
b228a68919
@ -110,7 +110,7 @@
|
||||
local count
|
||||
repeat
|
||||
value, count = value:gsub("%%{(.-)}", function(token)
|
||||
local result, err = expandtoken(token, environ)
|
||||
local result, err = expandtoken(token:gsub("\\", "\\\\"), environ)
|
||||
if not result then
|
||||
error(err, 0)
|
||||
end
|
||||
@ -139,8 +139,7 @@
|
||||
end
|
||||
return value
|
||||
else
|
||||
-- escape backslashes: they will break loadstring
|
||||
return expandvalue(value:gsub("\\", "\\\\"))
|
||||
return expandvalue(value)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -129,3 +129,13 @@
|
||||
x = detoken.expand("%{foo:gsub('/', '\\')}", environ)
|
||||
test.isequal("some\\path", x)
|
||||
end
|
||||
|
||||
--
|
||||
-- Escapes backslashes correctly, but not outside tokens.
|
||||
--
|
||||
|
||||
function suite.escapesBackslashes2()
|
||||
environ.foo = "some/path"
|
||||
x = detoken.expand("%{foo:gsub('/', '\\')}\\already\\escaped", environ)
|
||||
test.isequal("some\\path\\already\\escaped", x)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user