forked from redo/BlockLua
Ensure fn is a string path
This commit is contained in:
@@ -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(' +$', '')
|
||||||
|
|||||||
Reference in New Issue
Block a user