changeset 5590:b681948a01f1

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
author Kim Alvefur <zash@zash.se>
date Mon, 10 Jul 2023 16:10:57 +0200
parents 7040d0772758
children c7e532ac6bf7
files mod_http_muc_log/mod_http_muc_log.lua
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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