diff --git a/lua/lualine/utils/loader.lua b/lua/lualine/utils/loader.lua index 8ef0dd0..049d09e 100644 --- a/lua/lualine/utils/loader.lua +++ b/lua/lualine/utils/loader.lua @@ -1,8 +1,10 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. local notice = require'lualine.utils.notices' +local utils = require'lualine.utils.utils' local function lualine_load(patern, use_cache) + assert(utils.is_valid_filename(patern[#patern]), "Invalid filename") local retval, cache_name = nil, nil local sep = package.config:sub(1,1) diff --git a/lua/lualine/utils/utils.lua b/lua/lualine/utils/utils.lua index 706c326..3910834 100644 --- a/lua/lualine/utils/utils.lua +++ b/lua/lualine/utils/utils.lua @@ -75,4 +75,9 @@ function M.is_focused() return tonumber(vim.g.actual_curwin) == vim.fn.win_getid() end +function M.is_valid_filename(name) + local invalid_chars="[^a-zA-Z0-9_. ]" + return name:find(invalid_chars) == nil +end + return M