Parse special characters out of search strings and replace with spaces.

Этот коммит содержится в:
JoramWilander
2015-10-06 12:38:42 -04:00
родитель 4c297d05f7
Коммит 8a0d0bfa25
2 изменённых файлов: 33 добавлений и 12 удалений

Просмотреть файл

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