aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_http_files.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2012-12-21 09:04:02 +0100
committerKim Alvefur <zash@zash.se>2012-12-21 09:04:02 +0100
commit5c0e25da68b8fe6b4ca70d1f6b85ef5de3fc2ced (patch)
treeb63e4c7674e6bd896bb1e663922f1afb3ebbd710 /plugins/mod_http_files.lua
parente19d7ebdde19520082aa64d930658aa0e01ea316 (diff)
downloadprosody-5c0e25da68b8fe6b4ca70d1f6b85ef5de3fc2ced.tar.gz
prosody-5c0e25da68b8fe6b4ca70d1f6b85ef5de3fc2ced.zip
mod_http_files: Escape paths in redirects
Diffstat (limited to 'plugins/mod_http_files.lua')
-rw-r--r--plugins/mod_http_files.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua
index c0d9b2ec..43094eb4 100644
--- a/plugins/mod_http_files.lua
+++ b/plugins/mod_http_files.lua
@@ -12,6 +12,7 @@ local lfs = require "lfs";
local os_date = os.date;
local open = io.open;
local stat = lfs.attributes;
+local build_path = require"socket.url".build_path;
local http_base = module:get_option_string("http_files_dir", module:get_option_string("http_path", "www_files"));
local dir_indices = module:get_option("http_files_index", { "index.html", "index.htm" });
@@ -78,7 +79,9 @@ function serve_file(event, path)
data = data.data;
elseif attr.mode == "directory" then
if full_path:sub(-1) ~= "/" then
- response_headers.location = orig_path.."/";
+ local path = { is_absolute = true, is_directory = true };
+ for dir in orig_path:gmatch("[^/]+") do path[#path+1]=dir; end
+ response_headers.location = build_path(path);
return 301;
end
for i=1,#dir_indices do