lib/dtutils/string - fixed _should_be_sanitized with new patterns
to detect non safe filename characters
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user