Skip to content

Commit 300bb9d

Browse files
committed
lib/dtutils/string - fixed _should_be_sanitized with new patterns
to detect non safe filename characters
1 parent 4f8df88 commit 300bb9d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/dtutils/string.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,16 @@ end
306306
local function _should_be_sanitized(str)
307307
local old_log_level = log.log_level()
308308
local result = false
309+
local SAFE_POSIX_FILENAME_CHARS <const> = "[^%w/._%-]+"
310+
local SAFE_WIN_FILENAME_CHARS <const> = "[^%w\\._%-:]+"
311+
312+
local pattern = SAFE_POSIX_STRING_CHARS
313+
if dt.configuration.running_os == "windows" then
314+
pattern = SAFE_WIN_STRING_CHARS
315+
end
316+
309317
log.log_level(dtutils_string.log_level)
310-
if string.match(str, "[^%g]") then
318+
if string.match(str, pattern) then
311319
result = true
312320
end
313321
log.log_level(old_log_level)

0 commit comments

Comments
 (0)