From a9e34f4f21db2a290905929e6221eb5aa79f0192 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sat, 10 May 2014 11:04:59 +0200 Subject: [PATCH] Fix default landing mechanism if we fail to find a handler for the current URL, we redirect to landing, forcing a go. If i.e. a RSS gives a false link, the session then is moved to the lobby, which is bad. --- webcit/context_loop.c | 2 +- webcit/roomops.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/webcit/context_loop.c b/webcit/context_loop.c index a04c711bf..2a6fe162d 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -344,7 +344,7 @@ int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf) int return_value; StrBuf *NewLine = NewStrBuf(); Hdr->HR.DontNeedAuth = 1; - StrBufAppendPrintf(NewLine, "GET /landing?go=%s HTTP/1.0", ChrPtr(Buf)); + StrBufAppendPrintf(NewLine, "GET /landing?go=%s?failvisibly=1 HTTP/1.0", ChrPtr(Buf)); syslog(LOG_DEBUG, "Replacing with: %s", ChrPtr(NewLine)); return_value = ReadHttpSubject(Hdr, NewLine, Buf); FreeStrBuf(&NewLine); diff --git a/webcit/roomops.c b/webcit/roomops.c index 8720aecbc..cf0b370bb 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -127,8 +127,10 @@ void dotgoto(void) { * goto next room */ void smart_goto(const StrBuf *next_room) { - gotoroom(next_room); - readloop(readnew, eUseDefault); + if (gotoroom(next_room) == 2) + readloop(readnew, eUseDefault); + else + do_404(); } /* @@ -182,6 +184,10 @@ long gotoroom(const StrBuf *gname) long err = 0; int room_name_supplied = 0; int is_baseroom = 0; + int failvisibly; + + /* on fail, should we fallback to _BASEROOM_? */ + failvisibly = ibstr("failvisibly"); /* store ungoto information */ if (StrLength(gname) > 0) { @@ -206,6 +212,10 @@ long gotoroom(const StrBuf *gname) } StrBuf_ServGetln(Buf); if (GetServerStatus(Buf, &err) != 2) { + if (failvisibly) { + FreeStrBuf(&Buf); + return err; + } serv_puts("GOTO _BASEROOM_"); StrBuf_ServGetln(Buf); /* -- 2.30.2