Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json_encode() assert false on c0 or c1 utf-8 chars #28683

Open
altermo opened this issue May 9, 2024 · 1 comment · May be fixed by #28991
Open

json_encode() assert false on c0 or c1 utf-8 chars #28683

altermo opened this issue May 9, 2024 · 1 comment · May be fixed by #28991
Labels
bug-crash issue reporting a crash or segfault unicode 💩 (multibyte) unicode characters vimscript
Milestone

Comments

@altermo
Copy link
Contributor

altermo commented May 9, 2024

Problem

When passing a c0 or c1 UTF-8 char (except for \xc0\x80) to json_encode() it will make an assert fail (if neovim is built with debug).

(c0 and c1 UTF-8 characters are the extended versions of the normal ascii characters and are considered invalid (though vim and neovim sometimes handle them fine))

Steps to reproduce

nvim --clean
:echo json_encode("\xc0\x81")

Expected behavior

Don't fail assert.

Neovim version (nvim -v)

v0.10.0-dev-c18d794 (built with Debug)

Vim (not Nvim) behaves the same?

no, vim 9.1

Operating system/version

linux 6.8.9-arch1-2

Terminal name/version

kitty 0.33.1

$TERM environment variable

xterm-kitty

Installation

build from repo

@altermo altermo added the bug issues reporting wrong behavior label May 9, 2024
@zeertzjq zeertzjq added vimscript bug-crash issue reporting a crash or segfault unicode 💩 (multibyte) unicode characters and removed bug issues reporting wrong behavior labels May 9, 2024
@justinmk justinmk added this to the backlog milestone May 11, 2024
@justinmk
Copy link
Member

vim.json.encode("\xc0\x81") seems to work. We should consider changing json_encode / json_decode so that they simply call vim.json.

@glepnir glepnir linked a pull request May 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-crash issue reporting a crash or segfault unicode 💩 (multibyte) unicode characters vimscript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants