diff --git a/src/lua/box_net_box.lua b/src/lua/box_net_box.lua index 1c36bc7dd2b215dee448b970a309b0e875f9b5d5..f8c49c404460a9ad8e7ff5c8fcda3012869447ad 100644 --- a/src/lua/box_net_box.lua +++ b/src/lua/box_net_box.lua @@ -465,8 +465,9 @@ local remote_methods = { eval_str = eval_str .. tostring(arg) else arg = tostring(arg) - arg = string.gsub(arg, '"', '\\"') - eval_str = eval_str .. '"' .. arg .. '"' + arg = string.gsub(arg, ']]', ']].."]]"..[[') + arg = string.gsub(arg, "\n", ']].."\\n"..[[') + eval_str = eval_str .. '[[' .. arg .. ']]' end end eval_str = eval_str .. ")\n" diff --git a/test/box/box.net.box.result b/test/box/box.net.box.result index 39116cb9ae7caa12bfffc57dcd01aadc6b3eeed4..cff52613a1efba569afdbfcaa5704615acf0de27 100644 --- a/test/box/box.net.box.result +++ b/test/box/box.net.box.result @@ -573,6 +573,26 @@ cnc:call('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 remote:new(LISTEN.host, LISTEN.service, { user = 'test' }) --- diff --git a/test/box/box.net.box.test.lua b/test/box/box.net.box.test.lua index 2839f9eb834b96bce96fbfa101a55f3eb3f6dfb9..635b087a5a0d910687b049731e878ca3f453cf81 100644 --- a/test/box/box.net.box.test.lua +++ b/test/box/box.net.box.test.lua @@ -224,6 +224,12 @@ cnc:call('console_unpack_test', 1) cn: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 remote:new(LISTEN.host, LISTEN.service, { user = 'test' })