MM-22247: Space in content-type breaks integration with 3rd party apps (#13839)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
34668511cf
Коммит
c8a923d9e3
@@ -5,6 +5,7 @@ package web
|
||||
|
||||
import (
|
||||
"io"
|
||||
"mime"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@@ -28,7 +29,11 @@ func incomingWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var err *model.AppError
|
||||
incomingWebhookPayload := &model.IncomingWebhookRequest{}
|
||||
contentType := r.Header.Get("Content-Type")
|
||||
mediaType, _, mimeErr := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if mimeErr != nil && mimeErr != mime.ErrInvalidMediaParameter {
|
||||
c.Err = model.NewAppError("incomingWebhook", "api.webhook.incoming.error", nil, mimeErr.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if *c.App.Config().LogSettings.EnableWebhookDebugging {
|
||||
@@ -38,7 +43,7 @@ func incomingWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}()
|
||||
|
||||
if strings.Split(contentType, "; ")[0] == "application/x-www-form-urlencoded" {
|
||||
if mediaType == "application/x-www-form-urlencoded" {
|
||||
payload := strings.NewReader(r.FormValue("payload"))
|
||||
|
||||
incomingWebhookPayload, err = decodePayload(payload)
|
||||
@@ -46,7 +51,7 @@ func incomingWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
} else if strings.HasPrefix(contentType, "multipart/form-data") {
|
||||
} else if mediaType == "multipart/form-data" {
|
||||
r.ParseMultipartForm(0)
|
||||
|
||||
decoder := schema.NewDecoder()
|
||||
|
||||
Ссылка в новой задаче
Block a user