Skip to content

Commit d754e37

Browse files
committed
Properly sanitize filenames in dtutils.file file_copy and file_move.
1 parent 3d1f12f commit d754e37

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/dtutils/file.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,9 @@ function dtutils_file.file_copy(fromFile, toFile)
522522
local result = nil
523523
-- if cp exists, use it
524524
if dt.configuration.running_os == "windows" then
525-
result = os.execute('copy "' .. fromFile .. '" "' .. toFile .. '"')
525+
result = os.execute('copy ' .. dtutils_file.sanitize_filename(fromFile) .. ' ' .. dtutils_file.sanitize_filename(toFile))
526526
elseif dtutils_file.check_if_bin_exists("cp") then
527-
result = os.execute("cp '" .. fromFile .. "' '" .. toFile .. "'")
527+
result = os.execute("cp " .. dtutils_file.sanitize_filename(fromFile) .. ' ' .. dtutils_file.sanitize_filename(toFile))
528528
end
529529

530530
-- if cp was not present, or if cp failed, then a pure lua solution
@@ -575,7 +575,7 @@ function dtutils_file.file_move(fromFile, toFile)
575575
if not success then
576576
-- an error occurred, so let's try using the operating system function
577577
if dtutils_file.check_if_bin_exists("mv") then
578-
success = os.execute("mv '" .. fromFile .. "' '" .. toFile .. "'")
578+
success = os.execute("mv " .. dtutils_file.sanitize_filename(fromFile) .. ' ' .. dtutils_file.sanitize_filename(toFile))
579579
end
580580
-- if the mv didn't exist or succeed, then...
581581
if not success then

0 commit comments

Comments
 (0)