From b33fe456f80754c0bc6fb6c8ef6a72b7b107f55f Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 2 Mar 2016 16:42:59 +0100 Subject: mod_welcome: Use type-specific config API --- plugins/mod_welcome.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_welcome.lua b/plugins/mod_welcome.lua index 9c0c821b..cd5118a7 100644 --- a/plugins/mod_welcome.lua +++ b/plugins/mod_welcome.lua @@ -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") or "Hello $username, welcome to the $host IM server!"; local st = require "util.stanza"; -- cgit v1.2.3 From 89d089700746356babbe0af4251a95d9bf23b65e Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 2 Mar 2016 16:43:42 +0100 Subject: mod_welcome: Pass default text to config API as default value --- plugins/mod_welcome.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_welcome.lua b/plugins/mod_welcome.lua index cd5118a7..d74643de 100644 --- a/plugins/mod_welcome.lua +++ b/plugins/mod_welcome.lua @@ -7,7 +7,7 @@ -- local host = module:get_host(); -local welcome_text = module:get_option_string("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"; -- cgit v1.2.3 From cbe3f15ee4df20b4a5aa0edf44c86af52310fe8d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 3 Mar 2016 15:28:07 +0100 Subject: mod_http_files: Fix traceback when serving a non-wildcard path (fixes #611) --- plugins/mod_http_files.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'plugins') 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 -- cgit v1.2.3 From e08144940d172498352d9966016bb2c6f0f04913 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 3 Mar 2016 15:30:00 +0100 Subject: mod_http_files: Don't prepend / to path twice, sanitize path does this already --- plugins/mod_http_files.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua index 097f8346..fc39628c 100644 --- a/plugins/mod_http_files.lua +++ b/plugins/mod_http_files.lua @@ -95,7 +95,7 @@ function serve(opts) 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; -- cgit v1.2.3 From ae72fdd667dcc0fed977c1d0f20cc052390b6f1d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 3 Mar 2016 15:31:46 +0100 Subject: mod_http_files: Preserve a trailing / in paths (fixes #639) --- plugins/mod_http_files.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua index fc39628c..53b6469b 100644 --- a/plugins/mod_http_files.lua +++ b/plugins/mod_http_files.lua @@ -75,6 +75,9 @@ function sanitize_path(path) out[c] = component; end end + if path:sub(-1,-1) == "/" then + out[c+1] = ""; + end return "/"..table.concat(out, "/"); end -- cgit v1.2.3