Skip to content

Commit

Permalink
Sanitize null bytes in eval'ed text
Browse files Browse the repository at this point in the history
  • Loading branch information
yut23 committed Sep 25, 2023
1 parent c46341e commit b3084a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pythonx/UltiSnips/vim_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
2 changes: 0 additions & 2 deletions test/test_Fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b3084a3

Please sign in to comment.