Merge pull request #469 from wpferguson/win_sanitize

Sanitize windows command interactions
This commit is contained in:
wpferguson
2024-06-06 13:01:55 -04:00
committed by GitHub
16 changed files with 99 additions and 33 deletions

View File

@@ -31,6 +31,7 @@
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
du.check_min_api_version("7.0.0", "executable_manager")
@@ -75,7 +76,7 @@ local function grep(file, pattern)
if dt.configuration.running_os == "windows" then
-- use find to get the matches
local command = "\\windows\\system32\\find.exe " .. "\"" .. pattern .. "\"" .. " " .. file
local f = io.popen(command)
local f = dtsys.io_popen(command)
local output = f:read("all")
f:close()
-- strip out the first line
@@ -84,7 +85,7 @@ local function grep(file, pattern)
else
-- use grep and just return the answers
local command = "grep " .. pattern .. " " .. file
local f = io.popen(command)
local f = dtsys.io_popen(command)
local output = f:read("all")
f:close()
result = du.split(output, "\n")