Fix SQL syntax error when a non-existant channelId is attemted to be viewed. (#9975)

Этот коммит содержится в:
Christopher Speller
2018-12-12 10:08:55 -08:00
коммит произвёл GitHub
родитель 749a3e7538
Коммит fb12a739e5
4 изменённых файлов: 45 добавлений и 31 удалений

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

@@ -917,7 +917,7 @@ func viewChannel(c *Context, w http.ResponseWriter, r *http.Request) {
}
view := model.ChannelViewFromJson(r.Body)
if view == nil {
if view == nil || !model.IsValidId(view.ChannelId) || (view.PrevChannelId != "" && !model.IsValidId(view.PrevChannelId)) {
c.SetInvalidParam("channel_view")
return
}

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

@@ -1416,7 +1416,17 @@ func TestViewChannel(t *testing.T) {
view.PrevChannelId = "junk"
_, resp = Client.ViewChannel(th.BasicUser.Id, view)
CheckNoError(t, resp)
CheckBadRequestStatus(t, resp)
view.PrevChannelId = ""
view.ChannelId = "junk"
_, resp = Client.ViewChannel(th.BasicUser.Id, view)
CheckBadRequestStatus(t, resp)
view.ChannelId = "correctlysizedjunkdddfdfdf"
_, resp = Client.ViewChannel(th.BasicUser.Id, view)
CheckBadRequestStatus(t, resp)
view.ChannelId = th.BasicChannel.Id
member, resp := Client.GetChannelMember(th.BasicChannel.Id, th.BasicUser.Id, "")
CheckNoError(t, resp)