From 38b909e686f7ec77ec31fe7c0efe04e118a523a7 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 26 Sep 2015 19:34:58 +0200 Subject: mod_http_files: Strip trailing directory separator regardless of directionality of the slash (fixes #545) --- plugins/mod_http_files.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mod_http_files.lua') diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua index 3a9368b9..9d81f540 100644 --- a/plugins/mod_http_files.lua +++ b/plugins/mod_http_files.lua @@ -62,7 +62,7 @@ function serve(opts) local request, response = event.request, event.response; local orig_path = request.path; local full_path = base_path .. (path and "/"..path or ""); - local attr = stat((full_path:gsub('%'..path_sep..'+$',''))); + local attr = stat(full_path:match("^.*[^\\/]")); -- Strip trailing path separator because Windows if not attr then return 404; end -- cgit v1.2.3 From b7b28af321e349cac16f2a9709fe9d618d5d8bf0 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 26 Sep 2015 19:35:56 +0200 Subject: mod_http_files: Translate forward slashes to local directory separators --- plugins/mod_http_files.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mod_http_files.lua') diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua index 9d81f540..9839fed9 100644 --- a/plugins/mod_http_files.lua +++ b/plugins/mod_http_files.lua @@ -61,7 +61,7 @@ function serve(opts) local function serve_file(event, path) local request, response = event.request, event.response; local orig_path = request.path; - local full_path = base_path .. (path and "/"..path or ""); + local full_path = base_path .. (path and "/"..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