# HG changeset patch # User Kim Alvefur # Date 1457017576 -3600 # Node ID db0dc08929e749496a5462a2fc804654403fe1bc # Parent a74f0b7be6bf41cac1649a7858f0a77d2d624757# Parent c018a44b822a8efd82f2051c89a00b0db190ad3c Merge 0.10->trunk diff -r a74f0b7be6bf -r db0dc08929e7 plugins/mod_http_files.lua --- a/plugins/mod_http_files.lua Wed Mar 02 16:34:34 2016 +0100 +++ b/plugins/mod_http_files.lua Thu Mar 03 16:06:16 2016 +0100 @@ -56,6 +56,7 @@ local urldecode = require "util.http".urldecode; function sanitize_path(path) + if not path then return end local out = {}; local c = 0; @@ -74,6 +75,9 @@ out[c] = component; end end + if path:sub(-1,-1) == "/" then + out[c+1] = ""; + end return "/"..table.concat(out, "/"); end @@ -88,12 +92,13 @@ 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 full_path = base_path .. (path or ""):gsub("/", path_sep); local attr = stat(full_path:match("^.*[^\\/]")); -- Strip trailing path separator because Windows if not attr then return 404; diff -r a74f0b7be6bf -r db0dc08929e7 plugins/mod_welcome.lua --- a/plugins/mod_welcome.lua Wed Mar 02 16:34:34 2016 +0100 +++ b/plugins/mod_welcome.lua Thu Mar 03 16:06:16 2016 +0100 @@ -7,7 +7,7 @@ -- local host = module:get_host(); -local welcome_text = module:get_option("welcome_message") or "Hello $username, welcome to the $host IM server!"; +local welcome_text = module:get_option_string("welcome_message", "Hello $username, welcome to the $host IM server!"); local st = require "util.stanza";