From b3084a30ed3067030375e1f910f1916a4d1b1789 Mon Sep 17 00:00:00 2001 From: yut23 Date: Sun, 24 Sep 2023 21:34:23 -0400 Subject: [PATCH] Sanitize null bytes in eval'ed text --- pythonx/UltiSnips/vim_helper.py | 3 +++ test/test_Fixes.py | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pythonx/UltiSnips/vim_helper.py b/pythonx/UltiSnips/vim_helper.py index 513c5488..e295abcc 100755 --- a/pythonx/UltiSnips/vim_helper.py +++ b/pythonx/UltiSnips/vim_helper.py @@ -120,6 +120,9 @@ def command(cmd): def eval(text): """Wraps vim.eval.""" + # Replace null bytes with newlines, as vim raises a ValueError and neovim + # treats it as a terminator for the entire command. + text = text.replace("\x00", "\n") return vim.eval(text) diff --git a/test/test_Fixes.py b/test/test_Fixes.py index 344ef036..495dc2a8 100644 --- a/test/test_Fixes.py +++ b/test/test_Fixes.py @@ -135,14 +135,12 @@ class PassThroughNonexecutedTrigger(_VimTest): NULL_BYTE = CTRL_V + "000" -@unittest.expectedFailure class NullByte_ListSnippets(_VimTest): snippets = ("word", "never expanded", "", "w") keys = "foobar" + NULL_BYTE + LS + "\n" wanted = "foobar\x00\n" -@unittest.expectedFailure class NullByte_ExpandAfter(_VimTest): snippets = ("test", "Expand me!", "", "w") keys = "foobar " + NULL_BYTE + "test" + EX