diff options
author | Matthew Wild <mwild1@gmail.com> | 2012-04-26 16:48:16 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2012-04-26 16:48:16 +0100 |
commit | e64c982be472e25835cf9bf9f14efb131b73aece (patch) | |
tree | 7db3b0608d0e9271c3f2827877ee249c3744921a /plugins/mod_http_files.lua | |
parent | 1e12e0070326cb85095bd48c932c70d975928f95 (diff) | |
download | prosody-e64c982be472e25835cf9bf9f14efb131b73aece.tar.gz prosody-e64c982be472e25835cf9bf9f14efb131b73aece.zip |
mod_http_files, net.http.parser: Move path normalization to net.http.parser so that all modules can benefit
Diffstat (limited to 'plugins/mod_http_files.lua')
-rw-r--r-- | plugins/mod_http_files.lua | 24 |
1 files changed, 1 insertions, 23 deletions
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"); |