# HG changeset patch # User Kim Alvefur # Date 1614180956 -3600 # Node ID a3be7b3cf1e1aa98138957b4cb0c936de8c49ace # Parent 228bd43fbc3d818b6715cb27315b671d7804b6e3 mod_http_file_share: Fix traceback on missing file-type attempt to index a nil value (local 'filetype') casued by the :gsub call diff -r 228bd43fbc3d -r a3be7b3cf1e1 plugins/mod_http_file_share.lua --- 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";