From 23a8d954d9c18de6dc6187ba9af7539e81b33d91 Mon Sep 17 00:00:00 2001 From: Alex Polozov Date: Tue, 5 Jan 2016 18:54:23 -0800 Subject: [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. --- web/web.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'web') 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"))) -- cgit v1.2.3-1-g7c22