mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
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.
This commit is contained in:
parent
ab3a7fc3e3
commit
674f2513d4
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user