MM_22682_Centralize_ID_Validation (#14237)

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Shibasis Patel
2020-05-07 22:57:35 +05:30
коммит произвёл GitHub
родитель ef5ac519d9
Коммит 882b0324b5
36 изменённых файлов: 93 добавлений и 93 удалений

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

@@ -428,7 +428,7 @@ func createDirectChannel(c *Context, w http.ResponseWriter, r *http.Request) {
}
for _, id := range userIds {
if len(id) != 26 {
if !model.IsValidId(id) {
c.SetInvalidParam("user_id")
return
}
@@ -507,7 +507,7 @@ func createGroupChannel(c *Context, w http.ResponseWriter, r *http.Request) {
found := false
for _, id := range userIds {
if len(id) != 26 {
if !model.IsValidId(id) {
c.SetInvalidParam("user_id")
return
}
@@ -774,7 +774,7 @@ func getPublicChannelsByIdsForTeam(c *Context, w http.ResponseWriter, r *http.Re
}
for _, cid := range channelIds {
if len(cid) != 26 {
if !model.IsValidId(cid) {
c.SetInvalidParam("channel_id")
return
}
@@ -1359,7 +1359,7 @@ func addChannelMember(c *Context, w http.ResponseWriter, r *http.Request) {
props := model.StringInterfaceFromJson(r.Body)
userId, ok := props["user_id"].(string)
if !ok || len(userId) != 26 {
if !ok || !model.IsValidId(userId) {
c.SetInvalidParam("user_id")
return
}
@@ -1370,7 +1370,7 @@ func addChannelMember(c *Context, w http.ResponseWriter, r *http.Request) {
}
postRootId, ok := props["post_root_id"].(string)
if ok && len(postRootId) != 0 && len(postRootId) != 26 {
if ok && len(postRootId) != 0 && !model.IsValidId(postRootId) {
c.SetInvalidParam("post_root_id")
return
}
@@ -1539,7 +1539,7 @@ func updateChannelScheme(c *Context, w http.ResponseWriter, r *http.Request) {
}
schemeID := model.SchemeIDFromJson(r.Body)
if schemeID == nil || len(*schemeID) != 26 {
if schemeID == nil || !model.IsValidId(*schemeID) {
c.SetInvalidParam("scheme_id")
return
}
@@ -1606,7 +1606,7 @@ func channelMembersMinusGroupMembers(c *Context, w http.ResponseWriter, r *http.
groupIDs := []string{}
for _, gid := range strings.Split(c.Params.GroupIDs, ",") {
if len(gid) != 26 {
if !model.IsValidId(gid) {
c.SetInvalidParam("group_ids")
return
}