diff --git a/frontend/util.lua b/frontend/util.lua index 7e22edddf..65e306009 100644 --- a/frontend/util.lua +++ b/frontend/util.lua @@ -948,14 +948,17 @@ end --- Replaces characters that are invalid filenames. -- --- Replaces the characters \/:*?"<>| with an _. +-- Replaces the characters \/:*?"<>| with an _ +-- and removes trailing dots and spaces, in line with . -- These characters are problematic on Windows filesystems. On Linux only -- / poses a problem. ---- @string str filename ---- @treturn string sanitized filename local function replaceAllInvalidChars(str) if str then - return str:gsub('[\\/:*?"<>|]', '_') + str = str:gsub('[\\/:*?"<>|]', '_') + str = str:gsub("[.%s]+$", "") + return str end end