diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index ff83be44102..56561c6168d 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -2127,13 +2127,6 @@ func UpdateCommentContent(ctx *context.Context) { return } - if comment.Type == models.CommentTypeComment { - if err := comment.LoadAttachments(); err != nil { - ctx.ServerError("LoadAttachments", err) - return - } - } - if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) { ctx.Error(http.StatusForbidden) return @@ -2155,6 +2148,17 @@ func UpdateCommentContent(ctx *context.Context) { return } + if ctx.FormBool("ignore_attachments") { + return + } + + if comment.Type == models.CommentTypeComment { + if err := comment.LoadAttachments(); err != nil { + ctx.ServerError("LoadAttachments", err) + return + } + } + if err := updateAttachments(comment, ctx.FormStrings("files[]")); err != nil { ctx.ServerError("UpdateAttachments", err) return diff --git a/web_src/js/markup/tasklist.js b/web_src/js/markup/tasklist.js index 24b29ddb7af..ea1a1f824a1 100644 --- a/web_src/js/markup/tasklist.js +++ b/web_src/js/markup/tasklist.js @@ -46,9 +46,10 @@ export function initMarkupTasklist() { const {updateUrl, context} = editContentZone.dataset; await $.post(updateUrl, { + ignore_attachments: true, _csrf: window.config.csrf, content: newContent, - context, + context }); rawContent.textContent = newContent;