From: Lunny Xiao Date: Sat, 17 Aug 2019 12:59:36 +0000 (+0800) Subject: upload support text/plain; charset=utf8 (#7899) X-Git-Tag: v1.9.2~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7dd726faeb8a7e0dd34705a1e1cd5d95d718afd8;p=gitea.git upload support text/plain; charset=utf8 (#7899) --- diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go index f85787bc59..aa2cc14cf9 100644 --- a/routers/api/v1/repo/release_attachment.go +++ b/routers/api/v1/repo/release_attachment.go @@ -183,7 +183,8 @@ func CreateReleaseAttachment(ctx *context.APIContext) { allowed := false for _, t := range allowedTypes { t := strings.Trim(t, " ") - if t == "*/*" || t == fileType { + if t == "*/*" || t == fileType || + strings.HasPrefix(fileType, t+";") { allowed = true break } diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 8913e63015..47fa8faaaa 100644 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -48,7 +48,8 @@ func UploadAttachment(ctx *context.Context) { allowed := false for _, t := range allowedTypes { t := strings.Trim(t, " ") - if t == "*/*" || t == fileType { + if t == "*/*" || t == fileType || + strings.HasPrefix(fileType, t+";") { allowed = true break } diff --git a/routers/repo/editor.go b/routers/repo/editor.go index 0d71e6d2e1..5b95b9391c 100644 --- a/routers/repo/editor.go +++ b/routers/repo/editor.go @@ -628,7 +628,8 @@ func UploadFileToServer(ctx *context.Context) { allowed := false for _, t := range setting.Repository.Upload.AllowedTypes { t := strings.Trim(t, " ") - if t == "*/*" || t == fileType { + if t == "*/*" || t == fileType || + strings.HasPrefix(fileType, t+";") { allowed = true break }