diff options
author | Lewis Russell <lewis6991@gmail.com> | 2022-01-27 09:42:59 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-27 10:42:59 +0100 |
commit | f9080b24c4f60c3772db2b6e713ea5a6a3b52f1e (patch) | |
tree | fc288ba0bbecc18b12779ad75d82f831d5de5a7e /runtime/lua/vim/treesitter/language.lua | |
parent | 2320f705c42cc7d51045b34516264f38abb7ecde (diff) | |
download | rneovim-f9080b24c4f60c3772db2b6e713ea5a6a3b52f1e.tar.gz rneovim-f9080b24c4f60c3772db2b6e713ea5a6a3b52f1e.tar.bz2 rneovim-f9080b24c4f60c3772db2b6e713ea5a6a3b52f1e.zip |
fix(ts): escape lang when loading parsers (#16668)
When trying to load a language parser, escape the value of
the language.
With language injection, the language might be picked up from the
buffer. If this value is erroneous it can cause `nvim_get_runtime_file`
to hard error.
E.g., the markdown expression `~~~{` will extract '{' as a language and
then try to get the parser using `parser/{*` as the pattern.
Diffstat (limited to 'runtime/lua/vim/treesitter/language.lua')
-rw-r--r-- | runtime/lua/vim/treesitter/language.lua | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/runtime/lua/vim/treesitter/language.lua b/runtime/lua/vim/treesitter/language.lua index 6f347ff25f..8b106108df 100644 --- a/runtime/lua/vim/treesitter/language.lua +++ b/runtime/lua/vim/treesitter/language.lua @@ -14,7 +14,7 @@ function M.require_language(lang, path, silent) return true end if path == nil then - local fname = 'parser/' .. lang .. '.*' + local fname = 'parser/' .. vim.fn.fnameescape(lang) .. '.*' local paths = a.nvim_get_runtime_file(fname, false) if #paths == 0 then if silent then |