Wallabag: match `text/html` mimetype as starting with rather than exactly (#11492)

Previously unnoticed or changed Wallabag behavior can provide a mimetype of for example `text/html; utf-8`, which wouldn't be an exact match to `text/html`.

Fixes #11481.
reviewable/pr11508/r1
Frans de Jonge 2 months ago committed by GitHub
parent 2fca0ee989
commit 3e7ab199e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -554,14 +554,15 @@ function Wallabag:download(article)
-- If the article links to a supported file, we will download it directly.
-- All webpages are HTML. Ignore them since we want the Wallabag EPUB instead!
if article.mimetype ~= "text/html" then
if type(article.mimetype) == "string" and article.mimetype:find("^text/html") then
logger.dbg("Wallabag: ignoring EPUB in favor of mimetype: ", article.mimetype)
if DocumentRegistry:hasProvider(nil, article.mimetype) then
file_ext = "."..DocumentRegistry:mimeToExt(article.mimetype)
item_url = article.url
-- A function represents `null` in our JSON.decode, because `nil` would just disappear.
-- In that case, fall back to the file extension.
elseif type(article.mimetype) == "function" and DocumentRegistry:hasProvider(article.url) then
file_ext = ""
file_ext = "."..util.getFileNameSuffix(article.url)
item_url = article.url
end
end

Loading…
Cancel
Save