diff options
author | Alex Polozov <apskim@users.noreply.github.com> | 2016-01-05 18:54:23 -0800 |
---|---|---|
committer | Alex Polozov <polozov@cs.washington.edu> | 2016-01-06 02:58:27 +0000 |
commit | 23a8d954d9c18de6dc6187ba9af7539e81b33d91 (patch) | |
tree | c1272edcfad7e1a986bc54c3e9253bd918c88542 /web/web.go | |
parent | 482158d2bbc59be80e916bd2197f0fc609d9bc73 (diff) | |
download | chat-23a8d954d9c18de6dc6187ba9af7539e81b33d91.tar.gz chat-23a8d954d9c18de6dc6187ba9af7539e81b33d91.tar.bz2 chat-23a8d954d9c18de6dc6187ba9af7539e81b33d91.zip |
[Fix #1669] Allow parameters in Content-Type of incoming webhook request
Mattermost currently does not allow optional parameters in the `Content-Type` of an incoming webhook request. Visual Studio Team Services's Slack integration sends its message with `Content-Type: application/json; charset=utf-8`, whereas Mattermost currently requires precisely `Content-Type: application/json`. This PR relaxes this check, looking only at the media part of the header.
Diffstat (limited to 'web/web.go')
-rw-r--r-- | web/web.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/web/web.go b/web/web.go index 6e0e8df32..1f693c873 100644 --- a/web/web.go +++ b/web/web.go @@ -1017,7 +1017,8 @@ func incomingWebhook(c *api.Context, w http.ResponseWriter, r *http.Request) { r.ParseForm() var parsedRequest *model.IncomingWebhookRequest - if r.Header.Get("Content-Type") == "application/json" { + contentType := r.Header.Get("Content-Type") + if strings.Split(contentType, "; ")[0] == "application/json" { parsedRequest = model.IncomingWebhookRequestFromJson(r.Body) } else { parsedRequest = model.IncomingWebhookRequestFromJson(strings.NewReader(r.FormValue("payload"))) |