diff options
author | JoramWilander <jwawilander@gmail.com> | 2015-10-06 12:38:42 -0400 |
---|---|---|
committer | JoramWilander <jwawilander@gmail.com> | 2015-10-06 12:38:42 -0400 |
commit | 8a0d0bfa257afaa84a50620f9c85b35df753d569 (patch) | |
tree | 23e5bfd62712584c9a75baf0a6b58203053ec437 /store/sql_post_store.go | |
parent | 4c297d05f7cfbcfc4011fa25b8badfc6883c2c22 (diff) | |
download | chat-8a0d0bfa257afaa84a50620f9c85b35df753d569.tar.gz chat-8a0d0bfa257afaa84a50620f9c85b35df753d569.tar.bz2 chat-8a0d0bfa257afaa84a50620f9c85b35df753d569.zip |
Parse special characters out of search strings and replace with spaces.
Diffstat (limited to 'store/sql_post_store.go')
-rw-r--r-- | store/sql_post_store.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/store/sql_post_store.go b/store/sql_post_store.go index 668f45fbb..8d62eaad0 100644 --- a/store/sql_post_store.go +++ b/store/sql_post_store.go @@ -396,6 +396,17 @@ func (s SqlPostStore) getParentsPosts(channelId string, offset int, limit int) S return storeChannel } +var specialSearchChar = []string{ + "<", + ">", + "+", + "-", + "(", + ")", + "~", + "@", +} + func (s SqlPostStore) Search(teamId string, userId string, terms string, isHashtagSearch bool) StoreChannel { storeChannel := make(StoreChannel) @@ -411,10 +422,10 @@ func (s SqlPostStore) Search(teamId string, userId string, terms string, isHasht } } - // @ has a speical meaning in INNODB FULLTEXT indexes and - // is reserved for calc'ing distances so you - // cannot escape it so we replace it. - terms = strings.Replace(terms, "@", " ", -1) + // these chars have speical meaning and can be treated as spaces + for _, c := range specialSearchChar { + terms = strings.Replace(terms, c, " ", -1) + } var posts []*model.Post |