Update mkdir.lua

This commit is contained in:
FusionPBX 2023-07-12 10:47:57 -06:00 committed by GitHub
parent 1f62c73b2d
commit d3cfa9c2bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -2,6 +2,11 @@
function mkdir(dir)
api = freeswitch.API();
dir = dir:gsub([[\]], "/");
--retrieve allowed characters and then use it to sanitize the dir variable
local allowed_chars = os.getenv("ALLOWED_CHARS") or "^%a%d%-%._~"
dir = dir:gsub("[^" .. allowed_chars .. "]", "")
if (package.config:sub(1,1) == "/") then
--unix
cmd = [[mkdir -p "]] .. dir .. [["]];
@ -9,7 +14,7 @@
--windows
cmd = [[mkdir "]] .. dir .. [["]];
end
-- os.execute(cmd);
api:executeString("system " .. cmd );
os.execute(cmd);
--api:executeString("system " .. cmd );
return cmd;
end