From 57ae3243f8ff7c968d577abe25bc4564ed67314f Mon Sep 17 00:00:00 2001 From: Azareal Date: Sat, 30 Dec 2017 06:45:29 +0000 Subject: [PATCH] Fixed a bug where /topics/ always errors out for guests. --- common/parser.go | 22 ++++++++++++++++++++++ routes.go | 13 +++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/common/parser.go b/common/parser.go index a6402fdf..75989c63 100644 --- a/common/parser.go +++ b/common/parser.go @@ -175,9 +175,31 @@ func PreparseMessage(msg string) string { msg = RunSshook("preparse_preassign", msg) } msg = html.EscapeString(msg) + /*var runes = []rune(msg) + msg = "" + //var inBold = false + //var unclosedBolds = 0 + for i := 0; i < len(runes); i++ { + char := runes[i] + if char == '&' && peek(i, 1, runes) == 'l' && peek(i, 2, runes) == 't' && peek(i, 2, runes) == ';' { + i += 2 + + } else { + msg += string(char) + } + }*/ return shortcodeToUnicode(msg) } +// TODO: Test this +// TODO: Use this elsewhere in the parser? +func peek(cur int, skip int, runes []rune) rune { + if (cur + skip) < len(runes) { + return runes[cur+skip] + } + return 0 // null byte +} + // TODO: Write a test for this // TODO: We need a lot more hooks here. E.g. To add custom media types and handlers. func ParseMessage(msg string, sectionID int, sectionType string /*, user User*/) string { diff --git a/routes.go b/routes.go index c7d919bd..e9671d2a 100644 --- a/routes.go +++ b/routes.go @@ -153,17 +153,14 @@ func routeTopics(w http.ResponseWriter, r *http.Request, user common.User) commo } // We need a list of the visible forums for Quick Topic + // ? - Would it be useful, if we could post in social groups from /topics/? var forumList []common.Forum for _, fid := range canSee { forum := common.Forums.DirtyGet(fid) - if forum.Name != "" && forum.Active { - // This bit's for quick topic, as we don't want unbound forums (e.g. ones in plugin_socialgroups) showing up - // ? - Would it be useful, if we could post in social groups from /topics/? - if (forum.ParentType == "" || forum.ParentType == "forum") && user.Loggedin { - fcopy := forum.Copy() - // TODO: Add a hook here for plugin_guilds - forumList = append(forumList, fcopy) - } + if forum.Name != "" && forum.Active && (forum.ParentType == "" || forum.ParentType == "forum") { + fcopy := forum.Copy() + // TODO: Add a hook here for plugin_guilds + forumList = append(forumList, fcopy) } }