[fix] util.getSafeFilename() default to worst-case scenario (#5036)

Also pass path from Wallabag plugin.

Fixes #5025.
pull/5040/head
Frans de Jonge 5 years ago committed by GitHub
parent de1146c0b5
commit 439f876ad8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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)

Loading…
Cancel
Save