neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 674f2513d4d43688a55913456e6c01ddacceb199
parent ab3a7fc3e3c0166f5792526699f035dd9e057ee9
Author: Christian Clason <c.clason@uni-graz.at>
Date:   Thu, 18 Jan 2024 15:12:03 +0100

fix(treesitter): validate language alias for injections

Problem: Parsed language annotations can be random garbage so
`nvim_get_runtime_file` throws an error.

Solution: Validate that `alias` is a valid language name before trying
to find a parser for it.

Diffstat:
Mruntime/lua/vim/treesitter/languagetree.lua | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua @@ -757,6 +757,11 @@ end) ---@param alias string language or filetype name ---@return string? # resolved parser name local function resolve_lang(alias) + -- validate that `alias` is a legal language + if not (alias and alias:match('[%w_]+') == alias) then + return + end + if has_parser(alias) then return alias end