mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[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:
committed by
Alex Polozov
parent
482158d2bb
commit
23a8d954d9
@@ -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")))
|
||||
|
||||
Reference in New Issue
Block a user