Software /
code /
prosody
Diff
plugins/mod_http_file_share.lua @ 11402:a3be7b3cf1e1
mod_http_file_share: Fix traceback on missing file-type
attempt to index a nil value (local 'filetype') casued by the :gsub call
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 24 Feb 2021 16:35:56 +0100 |
parent | 11398:a1f26d17d70f |
child | 11405:ce8291e89d67 |
line wrap: on
line diff
--- a/plugins/mod_http_file_share.lua Tue Feb 23 19:52:57 2021 +0100 +++ b/plugins/mod_http_file_share.lua Wed Feb 24 16:35:56 2021 +0100 @@ -336,6 +336,9 @@ return ferr or 410; end + if not filetype then + filetype = "application/octet-stream"; + end local disposition = "attachment"; if safe_types:contains(filetype) or safe_types:contains(filetype:gsub("/.*", "/*")) then disposition = "inline"; @@ -343,7 +346,7 @@ response.headers.last_modified = last_modified; response.headers.content_length = filesize; - response.headers.content_type = filetype or "application/octet-stream"; + response.headers.content_type = filetype; response.headers.content_disposition = string.format("%s; filename=%q", disposition, basename); response.headers.cache_control = "max-age=31556952, immutable";