# HG changeset patch # User Kim Alvefur # Date 1457015287 -3600 # Node ID b5b7ae2901e64183e7393ee36933c862ba76b2bd # Parent f911f929ca6c8efa13b000eeec5f636d309e001b mod_http_files: Fix traceback when serving a non-wildcard path (fixes #611) diff -r f911f929ca6c -r b5b7ae2901e6 plugins/mod_http_files.lua --- a/plugins/mod_http_files.lua Wed Mar 02 16:30:46 2016 +0100 +++ b/plugins/mod_http_files.lua Thu Mar 03 15:28:07 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; @@ -88,10 +89,11 @@ 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