From 439f876ad80de1a59740489f196411c693966b1e Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Wed, 22 May 2019 11:34:46 +0200 Subject: [PATCH] [fix] util.getSafeFilename() default to worst-case scenario (#5036) Also pass path from Wallabag plugin. Fixes #5025. --- frontend/util.lua | 6 +++--- plugins/wallabag.koplugin/main.lua | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/util.lua b/frontend/util.lua index 3fd9543c6..aa0a4e3fc 100644 --- a/frontend/util.lua +++ b/frontend/util.lua @@ -482,7 +482,7 @@ end ---- @treturn string function util.getSafeFilename(str, path, limit) local filename, suffix = util.splitFileNameSuffix(str) - local replaceFunc = replaceSlashChar + local replaceFunc = replaceAllInvalidChars local safe_filename -- VFAT supports a maximum of 255 UCS-2 characters, although it's probably treated as UTF-16 by Windows -- default to a slightly lower limit just in case @@ -490,8 +490,8 @@ function util.getSafeFilename(str, path, limit) if path then local file_system = util.getFilesystemType(path) - if file_system == "vfat" or file_system == "fuse.fsp" then - replaceFunc = replaceAllInvalidChars + if file_system ~= "vfat" and file_system ~= "fuse.fsp" then + replaceFunc = replaceSlashChar end end diff --git a/plugins/wallabag.koplugin/main.lua b/plugins/wallabag.koplugin/main.lua index ffe3bea0d..6e799ea64 100644 --- a/plugins/wallabag.koplugin/main.lua +++ b/plugins/wallabag.koplugin/main.lua @@ -297,7 +297,7 @@ end function Wallabag:download(article) local skip_article = false local item_url = "/api/entries/" .. article.id .. "/export.epub" - local title = util.getSafeFilename(article.title) + local title = util.getSafeFilename(article.title, self.directory) local local_path = self.directory .. article_id_prefix .. article.id .. article_id_postfix .. title .. ".epub" logger.dbg("Wallabag: DOWNLOAD: id: ", article.id) logger.dbg("Wallabag: DOWNLOAD: title: ", article.title)