From 7c5c2aea2ca88a0112c51c5eaf74209271d780c9 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 26 Apr 2012 16:48:16 +0100 Subject: mod_http_files, net.http.parser: Move path normalization to net.http.parser so that all modules can benefit --- plugins/mod_http_files.lua | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua index 932d2547..9be735b7 100644 --- a/plugins/mod_http_files.lua +++ b/plugins/mod_http_files.lua @@ -25,31 +25,9 @@ local mime_map = { css = "text/css"; }; -local function preprocess_path(path) - if path:sub(1,1) ~= "/" then - path = "/"..path; - end - local level = 0; - for component in path:gmatch("([^/]+)/") do - if component == ".." then - level = level - 1; - elseif component ~= "." then - level = level + 1; - end - if level < 0 then - return nil; - end - end - return path; -end - function serve_file(event, path) local response = event.response; - path = path and preprocess_path(path); - if not path then - return 400; - end - local full_path = http_base..path; + local full_path = http_base.."/"..path; if stat(full_path, "mode") == "directory" then if stat(full_path.."/index.html", "mode") == "file" then return serve_file(event, path.."/index.html"); -- cgit v1.2.3