aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-02-24 16:35:56 +0100
committerKim Alvefur <zash@zash.se>2021-02-24 16:35:56 +0100
commit0a5ac437b9b7399b80fdf3cc0253aa15d96da08f (patch)
tree1ef8930e5d368c9918b3e61783d08c808f5a0f90
parent40252c2cc7e127eea7a87de095f75b84689d6b37 (diff)
downloadprosody-0a5ac437b9b7399b80fdf3cc0253aa15d96da08f.tar.gz
prosody-0a5ac437b9b7399b80fdf3cc0253aa15d96da08f.zip
mod_http_file_share: Fix traceback on missing file-type
attempt to index a nil value (local 'filetype') casued by the :gsub call
-rw-r--r--plugins/mod_http_file_share.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua
index 17563ad2..4c588c82 100644
--- a/plugins/mod_http_file_share.lua
+++ b/plugins/mod_http_file_share.lua
@@ -336,6 +336,9 @@ function handle_download(event, path) -- GET /uploads/:slot+filename
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 @@ function handle_download(event, path) -- GET /uploads/:slot+filename
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";