[MM-18036] Sanitize sql LIKE terms on search endpoints (#12044)
* Sanitize sql LIKE terms on search endpoints * Add search term sanitization in additional places
Этот коммит содержится в:
коммит произвёл
Daniel Schalla
родитель
8b969426f0
Коммит
814c234443
@@ -293,6 +293,8 @@ func (s SqlTeamStore) GetByName(name string) (*model.Team, *model.AppError) {
|
||||
func (s SqlTeamStore) SearchAll(term string) ([]*model.Team, *model.AppError) {
|
||||
var teams []*model.Team
|
||||
|
||||
term = sanitizeSearchTerm(term, "\\")
|
||||
|
||||
if _, err := s.GetReplica().Select(&teams, "SELECT * FROM Teams WHERE Name LIKE :Term OR DisplayName LIKE :Term", map[string]interface{}{"Term": term + "%"}); err != nil {
|
||||
return nil, model.NewAppError("SqlTeamStore.SearchAll", "store.sql_team.search_all_team.app_error", nil, "term="+term+", "+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -303,6 +305,8 @@ func (s SqlTeamStore) SearchAll(term string) ([]*model.Team, *model.AppError) {
|
||||
func (s SqlTeamStore) SearchOpen(term string) ([]*model.Team, *model.AppError) {
|
||||
var teams []*model.Team
|
||||
|
||||
term = sanitizeSearchTerm(term, "\\")
|
||||
|
||||
if _, err := s.GetReplica().Select(&teams, "SELECT * FROM Teams WHERE Type = 'O' AND AllowOpenInvite = true AND (Name LIKE :Term OR DisplayName LIKE :Term)", map[string]interface{}{"Term": term + "%"}); err != nil {
|
||||
return nil, model.NewAppError("SqlTeamStore.SearchOpen", "store.sql_team.search_open_team.app_error", nil, "term="+term+", "+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -313,6 +317,8 @@ func (s SqlTeamStore) SearchOpen(term string) ([]*model.Team, *model.AppError) {
|
||||
func (s SqlTeamStore) SearchPrivate(term string) ([]*model.Team, *model.AppError) {
|
||||
var teams []*model.Team
|
||||
|
||||
term = sanitizeSearchTerm(term, "\\")
|
||||
|
||||
query :=
|
||||
`SELECT *
|
||||
FROM
|
||||
|
||||
Ссылка в новой задаче
Block a user