[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.
This commit is contained in:
Alex Polozov
2016-01-05 18:54:23 -08:00
committed by Alex Polozov
parent 482158d2bb
commit 23a8d954d9

View File

@@ -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")))