diff options
author | ZyX <kp-pav@yandex.ru> | 2016-02-11 01:29:09 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2016-04-18 02:47:13 +0300 |
commit | f0bd4a149408e75ebf887530964e0948518938dc (patch) | |
tree | 06c489c6a8b506a122a0d93448c7bc9418dd8b5b /test/functional/eval/json_functions_spec.lua | |
parent | 77776b09c684bc2a0c42114fce5a8b04409ec91d (diff) | |
download | rneovim-f0bd4a149408e75ebf887530964e0948518938dc.tar.gz rneovim-f0bd4a149408e75ebf887530964e0948518938dc.tar.bz2 rneovim-f0bd4a149408e75ebf887530964e0948518938dc.zip |
eval/encode: Fix invalid UTF-8 strings handling:
1. Do not allow reading past buffer end when creating error messages.
2. Fix surrogate pairs range, avoid magic constants.
Diffstat (limited to 'test/functional/eval/json_functions_spec.lua')
-rw-r--r-- | test/functional/eval/json_functions_spec.lua | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/functional/eval/json_functions_spec.lua b/test/functional/eval/json_functions_spec.lua index 13597eb7a0..398fab6c4b 100644 --- a/test/functional/eval/json_functions_spec.lua +++ b/test/functional/eval/json_functions_spec.lua @@ -663,4 +663,11 @@ describe('jsonencode() function', function() eq(1, eval('"\x01" =~# "\\\\p"')) eq('"\\u0001"', funcs.jsonencode('\x01')) end) + + it('fails when using surrogate character in a UTF-8 string', function() + eq('Vim(call):E474: UTF-8 string contains code point which belongs to a surrogate pair: \xED\xA0\x80', + exc_exec('call jsonencode("\xED\xA0\x80")')) + eq('Vim(call):E474: UTF-8 string contains code point which belongs to a surrogate pair: \xED\xAF\xBF', + exc_exec('call jsonencode("\xED\xAF\xBF")')) + end) end) |