Wikpedia EPUBs: fix failure saving some files

Since 8815cbe0 and getSafeFilename() taking additional
parameters, and :gsub() returning multiple values,
filesystem type wasn't really checked and replacements
were not ensured, so saving articles like "Portal:Stuff"
failed on VFAT devices as ':' wasn't replaced.
This commit is contained in:
poire-z
2020-09-18 12:40:43 +02:00
parent f1918cdfbb
commit 62d0cf5dfa
2 changed files with 9 additions and 7 deletions

View File

@@ -355,10 +355,6 @@ function DictQuickLookup:update()
-- if forced_lang was specified, it may not be in our wiki_languages,
-- but ReaderWikipedia will have put it in result.lang
local lang = self.lang or self.wiki_languages_copy[1]
-- Just to be safe (none of the invalid chars, except ':' for uninteresting
-- Portal: or File: wikipedia pages, should be in lookup_word)
local cleaned_lookupword = util.getSafeFilename(self.lookupword:gsub("_", " "))
local filename = cleaned_lookupword .. "."..string.upper(lang)..".epub"
-- Find a directory to save file into
local dir
if G_reader_settings:isTrue("wikipedia_save_in_book_dir") and not self:isDocless() then
@@ -376,6 +372,10 @@ function DictQuickLookup:update()
})
return
end
-- Just to be safe (none of the invalid chars, except ':' for uninteresting
-- Portal: or File: wikipedia pages, should be in lookupword)
local filename = self.lookupword .. "."..string.upper(lang)..".epub"
filename = util.getSafeFilename(filename, dir):gsub("_", " ")
local epub_path = dir .. "/" .. filename
UIManager:show(ConfirmBox:new{
text = T(_("Save as %1?"), BD.filename(filename)),