Mercurial > prosody-modules
comparison mod_http_muc_log/mod_http_muc_log.lua @ 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 | df483d9056f5 |
children | c20b77e5e032 |
comparison
equal
deleted
inserted
replaced
5589:7040d0772758 | 5590:b681948a01f1 |
---|---|
292 | 292 |
293 -- Produce the chat log view | 293 -- Produce the chat log view |
294 local function logs_page(event, path) | 294 local function logs_page(event, path) |
295 local request, response = event.request, event.response; | 295 local request, response = event.request, event.response; |
296 | 296 |
297 local room, date = path:match("^([^/]+)/([^/]*)/?$"); | 297 -- /room --> 303 /room/ |
298 if not room then | 298 -- /room/ --> calendar view |
299 -- /room/yyyy-mm-dd --> logs view | |
300 -- /room/yyyy-mm-dd/* --> 404 | |
301 local room, date = path:match("^([^/]+)/([^/]*)$"); | |
302 if not room and not path:find"/" then | |
299 response.headers.location = url.build({ path = path .. "/" }); | 303 response.headers.location = url.build({ path = path .. "/" }); |
300 return 303; | 304 return 303; |
305 elseif not room then | |
306 return 404; | |
301 end | 307 end |
302 room = nodeprep(room); | 308 room = nodeprep(room); |
303 if not room then | 309 if not room then |
304 return 400; | 310 return 400; |
305 elseif date == "" then | 311 elseif date == "" then |