mirror of
https://github.com/neovim/neovim.git
synced 2025-09-20 02:08:17 +00:00
eval/decode: Make sure that U+00C3 is parsed correctly
This commit is contained in:
@@ -431,7 +431,10 @@ json_decode_string_cycle_start:
|
|||||||
// and thus cannot possibly be equal to *p. But utf_ptr2char({0xFF,
|
// and thus cannot possibly be equal to *p. But utf_ptr2char({0xFF,
|
||||||
// 0}) will return 0xFF, even though 0xFF cannot start any UTF-8
|
// 0}) will return 0xFF, even though 0xFF cannot start any UTF-8
|
||||||
// code point at all.
|
// code point at all.
|
||||||
if (ch >= 0x80 && p_byte == ch) {
|
//
|
||||||
|
// The only exception is U+00C3 which is represented as 0xC3 0x83.
|
||||||
|
if (ch >= 0x80 && p_byte == ch && !(
|
||||||
|
ch == 0xC3 && p + 1 < e && (uint8_t) p[1] == 0x83)) {
|
||||||
EMSG2(_("E474: Only UTF-8 strings allowed: %s"), p);
|
EMSG2(_("E474: Only UTF-8 strings allowed: %s"), p);
|
||||||
goto json_decode_string_fail;
|
goto json_decode_string_fail;
|
||||||
} else if (ch > 0x10FFFF) {
|
} else if (ch > 0x10FFFF) {
|
||||||
|
@@ -447,6 +447,10 @@ describe('json_decode() function', function()
|
|||||||
eq('\xAB', funcs.json_decode('"\\u00AB"'))
|
eq('\xAB', funcs.json_decode('"\\u00AB"'))
|
||||||
sp_decode_eq({_TYPE='string', _VAL={'\n\xAB\n'}}, '"\\u0000\\u00AB\\u0000"')
|
sp_decode_eq({_TYPE='string', _VAL={'\n\xAB\n'}}, '"\\u0000\\u00AB\\u0000"')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('parses U+00C3 correctly', function()
|
||||||
|
eq('\xC3\x83', funcs.json_decode('"\xC3\x83"'))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('json_encode() function', function()
|
describe('json_encode() function', function()
|
||||||
|
Reference in New Issue
Block a user