diff options
author | oni-link <knil.ino@gmail.com> | 2015-12-19 11:29:39 +0100 |
---|---|---|
committer | oni-link <knil.ino@gmail.com> | 2015-12-21 00:23:53 +0100 |
commit | 8373aaf44e6a64dda135a11f275f4616afa23b63 (patch) | |
tree | 5e4a8950db5cc3b5d430e1cb8160c0c1aeca98f5 /test/functional/api/server_requests_spec.lua | |
parent | e123675bcce886c1da3d917fbd88ab38cda7eba5 (diff) | |
download | rneovim-8373aaf44e6a64dda135a11f275f4616afa23b63.tar.gz rneovim-8373aaf44e6a64dda135a11f275f4616afa23b63.tar.bz2 rneovim-8373aaf44e6a64dda135a11f275f4616afa23b63.zip |
helpers.c: Handle msgpack str/bin objects with length 0 correctly
When converting a msgpack object to a String object, strings (and byte
arrays) with length 0 are handled as errors. This is fixed by
always using the msgpack data pointer as a valid pointer. For a NULL
pointer there is nothing to copy.
Test by @snoe
Fixes #3844
Diffstat (limited to 'test/functional/api/server_requests_spec.lua')
-rw-r--r-- | test/functional/api/server_requests_spec.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index a3ac864f79..16a4423535 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -32,6 +32,26 @@ describe('server -> client', function() end) end) + describe('empty string handling in arrays', function() + -- Because the msgpack encoding for an empty string was interpreted as an + -- error, msgpack arrays with an empty string looked like + -- [..., '', 0, ..., 0] after the conversion, regardless of the array + -- elements following the empty string. + it('works', function() + local function on_setup() + eq({1, 2, '', 3, 'asdf'}, eval('rpcrequest('..cid..', "nstring")')) + stop() + end + + local function on_request(method, args) + -- No need to evaluate the args, we are only interested in + -- a response that contains an array with an empty string. + return {1, 2, '', 3, 'asdf'} + end + run(on_request, nil, on_setup) + end) + end) + describe('recursive call', function() it('works', function() local function on_setup() |