From 7dd726faeb8a7e0dd34705a1e1cd5d95d718afd8 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 17 Aug 2019 20:59:36 +0800 Subject: [PATCH] upload support text/plain; charset=utf8 (#7899) --- routers/api/v1/repo/release_attachment.go | 3 ++- routers/repo/attachment.go | 3 ++- routers/repo/editor.go | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) 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 }