lib/dtutils/string - fixed _should_be_sanitized with new patterns

to detect non safe filename characters
This commit is contained in:
Bill Ferguson
2024-10-19 22:04:56 -04:00
parent 4f8df88fec
commit 300bb9d443

View File

@@ -306,8 +306,16 @@ end
local function _should_be_sanitized(str)
local old_log_level = log.log_level()
local result = false
local SAFE_POSIX_FILENAME_CHARS <const> = "[^%w/._%-]+"
local SAFE_WIN_FILENAME_CHARS <const> = "[^%w\\._%-:]+"
local pattern = SAFE_POSIX_STRING_CHARS
if dt.configuration.running_os == "windows" then
pattern = SAFE_WIN_STRING_CHARS
end
log.log_level(dtutils_string.log_level)
if string.match(str, "[^%g]") then
if string.match(str, pattern) then
result = true
end
log.log_level(old_log_level)