mod_http_muc_log: Fix redirect bug
If you somehow went to /muc_log/room/yyyy-mm-dd/something it would send
you in a redirect loop that continuously added path components until the
path can't be parsed anymore.
This should ensure that /muc_log/room/date/ is simply 404'd
--- a/mod_http_muc_log/mod_http_muc_log.lua Mon Jul 10 07:16:54 2023 +0200
+++ b/mod_http_muc_log/mod_http_muc_log.lua Mon Jul 10 16:10:57 2023 +0200
@@ -294,10 +294,16 @@
local function logs_page(event, path)
local request, response = event.request, event.response;
- local room, date = path:match("^([^/]+)/([^/]*)/?$");
- if not room then
+ -- /room --> 303 /room/
+ -- /room/ --> calendar view
+ -- /room/yyyy-mm-dd --> logs view
+ -- /room/yyyy-mm-dd/* --> 404
+ local room, date = path:match("^([^/]+)/([^/]*)$");
+ if not room and not path:find"/" then
response.headers.location = url.build({ path = path .. "/" });
return 303;
+ elseif not room then
+ return 404;
end
room = nodeprep(room);
if not room then