Changed post searching to ignore requests to return everything by searching for *

This commit is contained in:
hmhealey
2015-11-04 10:30:32 -05:00
parent 559ca09f2c
commit 40e0ba37ca
2 changed files with 8 additions and 1 deletions

View File

@@ -890,7 +890,10 @@ func searchPosts(c *Context, w http.ResponseWriter, r *http.Request) {
channels := []store.StoreChannel{}
for _, params := range paramsList {
channels = append(channels, Srv.Store.Post().Search(c.Session.TeamId, c.Session.UserId, params))
// don't allow users to search for everything
if params.Terms != "*" {
channels = append(channels, Srv.Store.Post().Search(c.Session.TeamId, c.Session.UserId, params))
}
}
posts := &model.PostList{}

View File

@@ -450,6 +450,10 @@ func TestSearchPosts(t *testing.T) {
if len(r3.Order) != 1 && r3.Order[0] == post3.Id {
t.Fatal("wrong serach")
}
if r4 := Client.Must(Client.SearchPosts("*")).Data.(*model.PostList); len(r4.Order) != 0 {
t.Fatal("searching for just * shouldn't return any results")
}
}
func TestSearchHashtagPosts(t *testing.T) {