Ensure fn is a string path

This commit is contained in:
2025-12-08 03:32:12 -05:00
parent f6bf18efaa
commit 33f5ec9bbe

View File

@@ -62,6 +62,9 @@ local disallowed_exts = tmap {
-- Return: clean file path if allowed (or nil if disallowed), -- Return: clean file path if allowed (or nil if disallowed),
-- error string (or nil if allowed) -- error string (or nil if allowed)
local function safe_path(fn, readonly) local function safe_path(fn, readonly)
if type(fn) ~= 'string' then
return nil, 'Filename must be a string'
end
fn = fn:gsub('\\', '/') fn = fn:gsub('\\', '/')
fn = fn:gsub('^ +', '') fn = fn:gsub('^ +', '')
fn = fn:gsub(' +$', '') fn = fn:gsub(' +$', '')