Skip to content
Snippets Groups Projects
Commit 7791f39b authored by Roman Tsisyk's avatar Roman Tsisyk
Browse files

Fix #649: String escaping doesn't work in remote console

parent c9246f8f
No related branches found
No related tags found
No related merge requests found
...@@ -465,8 +465,9 @@ local remote_methods = { ...@@ -465,8 +465,9 @@ local remote_methods = {
eval_str = eval_str .. tostring(arg) eval_str = eval_str .. tostring(arg)
else else
arg = tostring(arg) arg = tostring(arg)
arg = string.gsub(arg, '"', '\\"') arg = string.gsub(arg, ']]', ']].."]]"..[[')
eval_str = eval_str .. '"' .. arg .. '"' arg = string.gsub(arg, "\n", ']].."\\n"..[[')
eval_str = eval_str .. '[[' .. arg .. ']]'
end end
end end
eval_str = eval_str .. ")\n" eval_str = eval_str .. ")\n"
......
...@@ -573,6 +573,26 @@ cnc:call('123') ...@@ -573,6 +573,26 @@ cnc:call('123')
--- ---
- error: '[string "123()"]:1: unexpected symbol near ''123''' - error: '[string "123()"]:1: unexpected symbol near ''123'''
... ...
-- gh-649: String escaping doesn't work in remote console
function echo(...) return ... end
---
...
#cn:call('echo', [[a \[\[ \091\091 b \093\093 c \n d \t e \]\] f ]])[1][1]
---
- 46
...
#cnc:call('echo', [[a \[\[ \091\091 b \093\093 c \n d \t e \]\] f ]])[1][1]
---
- 46
...
#cn:call('echo', "a [[ \091\091 b \093\093 c \n d \t e ]] f ")[1][1]
---
- 28
...
#cnc:call('echo', "a [[ \091\091 b \093\093 c \n d \t e ]] f ")[1][1]
---
- 28
...
-- #545 user or password is not defined -- #545 user or password is not defined
remote:new(LISTEN.host, LISTEN.service, { user = 'test' }) remote:new(LISTEN.host, LISTEN.service, { user = 'test' })
--- ---
......
...@@ -224,6 +224,12 @@ cnc:call('console_unpack_test', 1) ...@@ -224,6 +224,12 @@ cnc:call('console_unpack_test', 1)
cn:call('123') cn:call('123')
cnc:call('123') cnc:call('123')
-- gh-649: String escaping doesn't work in remote console
function echo(...) return ... end
#cn:call('echo', [[a \[\[ \091\091 b \093\093 c \n d \t e \]\] f ]])[1][1]
#cnc:call('echo', [[a \[\[ \091\091 b \093\093 c \n d \t e \]\] f ]])[1][1]
#cn:call('echo', "a [[ \091\091 b \093\093 c \n d \t e ]] f ")[1][1]
#cnc:call('echo', "a [[ \091\091 b \093\093 c \n d \t e ]] f ")[1][1]
-- #545 user or password is not defined -- #545 user or password is not defined
remote:new(LISTEN.host, LISTEN.service, { user = 'test' }) remote:new(LISTEN.host, LISTEN.service, { user = 'test' })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment