]> source.dussan.org Git - gitea.git/commitdiff
upload support text/plain; charset=utf8 (#7899)
authorLunny Xiao <xiaolunwen@gmail.com>
Sat, 17 Aug 2019 12:59:36 +0000 (20:59 +0800)
committerzeripath <art27@cantab.net>
Sat, 17 Aug 2019 12:59:36 +0000 (13:59 +0100)
routers/api/v1/repo/release_attachment.go
routers/repo/attachment.go
routers/repo/editor.go

index f85787bc592a2aec440e4a024690b094b3dfc07d..aa2cc14cf920b64c6f7a554a1a6e2cb7bbc60b25 100644 (file)
@@ -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
                }
index 8913e630150cc62e67ded7023ab642730af07a05..47fa8faaaa055ec665b5ba1b3ff71c7bf8ab4961 100644 (file)
@@ -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
                }
index 0d71e6d2e14722913e1a1173506edddc3924d1b1..5b95b9391c1f44e00517b49d8434ca4d49d422df 100644 (file)
@@ -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
                        }