Browse Source

Re add command sanitation

develop
Matthew Faltys 7 years ago
parent
commit
a300e80f7e
  1. 6
      lorebot/botfunc.go
  2. 7
      lorebot/lorebot.go

6
lorebot/botfunc.go

@ -34,6 +34,12 @@ func loreNewString(nick, newString, newType string, redisClient *redis.Client) e
stripContent := strings.Replace(fmt.Sprintf("%s", content), "<", "", -1) stripContent := strings.Replace(fmt.Sprintf("%s", content), "<", "", -1)
stripLinks := strings.Replace(stripContent, ">", "", -1) stripLinks := strings.Replace(stripContent, ">", "", -1)
// dont allow certain chars
if strings.ContainsAny(command, ";:,.'\"!$%^*()/\\") {
// reject user input, it has unwanted chars
return errors.New("error: entry contains unwanted characters")
}
t := time.Now() t := time.Now()
// create a timestamp to use // create a timestamp to use

7
lorebot/lorebot.go

@ -319,13 +319,6 @@ func lorestatus(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Clien
} }
func newhandler(rtm *slack.RTM, ev *slack.MessageEvent, message, newType string, redisClient *redis.Client) { func newhandler(rtm *slack.RTM, ev *slack.MessageEvent, message, newType string, redisClient *redis.Client) {
// dont allow certain chars
//if strings.ContainsAny(message, ";:,.'\"!$%^*()/\\") {
// // reject user input, it has unwanted chars
// rtm.SendMessage(rtm.NewOutgoingMessage("entry could not be created, unwanted characters", ev.Channel))
// return
//}
// get nick from slack api // get nick from slack api
user, err := rtm.GetUserInfo(ev.User) user, err := rtm.GetUserInfo(ev.User)
if err != nil { if err != nil {

Loading…
Cancel
Save