From eb806c96205ff776d9cd5df82da72c14e030f6d6 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 7 Mar 2016 08:54:39 +0300 Subject: eval/decode: Make sure that error messages do not cause overflow --- test/functional/eval/json_functions_spec.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/functional/eval/json_functions_spec.lua') diff --git a/test/functional/eval/json_functions_spec.lua b/test/functional/eval/json_functions_spec.lua index aa36b62757..58030fca72 100644 --- a/test/functional/eval/json_functions_spec.lua +++ b/test/functional/eval/json_functions_spec.lua @@ -448,6 +448,12 @@ describe('json_decode() function', function() sp_decode_eq({_TYPE='string', _VAL={'\n\xAB\n'}}, '"\\u0000\\u00AB\\u0000"') end) + it('fails to convert string to latin1 if it is impossible', function() + restart('set encoding=latin1') + eq('Vim(call):E474: Failed to convert string "ꯍ" from UTF-8', + exc_exec('call json_decode(\'"\\uABCD"\')')) + end) + it('parses U+00C3 correctly', function() eq('\xC3\x83', funcs.json_decode('"\xC3\x83"')) end) -- cgit