aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_http_files.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-03-03 15:28:07 +0100
committerKim Alvefur <zash@zash.se>2016-03-03 15:28:07 +0100
commitd4ec0ae3cde1dc5dba5a935e8c9926d63fb5a05a (patch)
tree8e55ca29a229457baa2827d3bc4462d93a3b15cc /plugins/mod_http_files.lua
parent170dbb45cc3604f3402ce700e2c9b4a249f961ab (diff)
downloadprosody-d4ec0ae3cde1dc5dba5a935e8c9926d63fb5a05a.tar.gz
prosody-d4ec0ae3cde1dc5dba5a935e8c9926d63fb5a05a.zip
mod_http_files: Fix traceback when serving a non-wildcard path (fixes #611)
Diffstat (limited to 'plugins/mod_http_files.lua')
-rw-r--r--plugins/mod_http_files.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua
index 6275cca5..097f8346 100644
--- a/plugins/mod_http_files.lua
+++ b/plugins/mod_http_files.lua
@@ -56,6 +56,7 @@ end
local urldecode = require "util.http".urldecode;
function sanitize_path(path)
+ if not path then return end
local out = {};
local c = 0;
@@ -88,10 +89,11 @@ function serve(opts)
local directory_index = opts.directory_index;
local function serve_file(event, path)
local request, response = event.request, event.response;
- path = sanitize_path(path);
- if not path then
+ local sanitized_path = sanitize_path(path);
+ if path and not sanitized_path then
return 400;
end
+ path = sanitized_path;
local orig_path = sanitize_path(request.path);
local full_path = base_path .. (path and "/"..path or ""):gsub("/", path_sep);
local attr = stat(full_path:match("^.*[^\\/]")); -- Strip trailing path separator because Windows