Fixed a bug where /topics/ always errors out for guests.

This commit is contained in:
Azareal 2017-12-30 06:45:29 +00:00
parent 547254c4a1
commit 57ae3243f8
2 changed files with 27 additions and 8 deletions

View File

@ -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 {

View File

@ -153,19 +153,16 @@ 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 {
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)
}
}
}
// ? - Should we be showing plugin_guilds posts on /topics/?
argList, qlist := common.ForumListToArgQ(forumList)