From 297afc5ce699823cca171aa0d44280e8b5e75b26 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 19 Nov 2020 09:27:59 -0500 Subject: Limit total size of unsent attachments --- plugins/base/routes.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'plugins/base') diff --git a/plugins/base/routes.go b/plugins/base/routes.go index c8d112e..3f379dd 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -692,7 +692,13 @@ func handleComposeAttachment(ctx *alps.Context) error { var uuids []string for _, fh := range form.File["attachments"] { uuid, err := ctx.Session.PutAttachment(fh, form) - if err != nil { + if err == alps.ErrAttachmentCacheSize { + form.RemoveAll() + return ctx.JSON(http.StatusBadRequest, map[string]string{ + "error": "The total size of unset attachments on your session exceeds the maximum file size. Remove some attachments and try again.", + }) + } else if err != nil { + form.RemoveAll() ctx.Logger().Printf("PutAttachment: %v\n", err) return ctx.JSON(http.StatusBadRequest, map[string]string{ "error": "failed to store attachment", -- cgit v1.2.3