mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	| @@ -3149,13 +3149,10 @@ func UpdateCommentContent(ctx *context.Context) { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	oldContent := comment.Content | 	oldContent := comment.Content | ||||||
| 	comment.Content = ctx.FormString("content") | 	newContent := ctx.FormString("content") | ||||||
| 	if len(comment.Content) == 0 { |  | ||||||
| 		ctx.JSON(http.StatusOK, map[string]any{ | 	// allow to save empty content | ||||||
| 			"content": "", | 	comment.Content = newContent | ||||||
| 		}) |  | ||||||
| 		return |  | ||||||
| 	} |  | ||||||
| 	if err = issue_service.UpdateComment(ctx, comment, ctx.Doer, oldContent); err != nil { | 	if err = issue_service.UpdateComment(ctx, comment, ctx.Doer, oldContent); err != nil { | ||||||
| 		if errors.Is(err, user_model.ErrBlockedUser) { | 		if errors.Is(err, user_model.ErrBlockedUser) { | ||||||
| 			ctx.JSONError(ctx.Tr("repo.issues.comment.blocked_user")) | 			ctx.JSONError(ctx.Tr("repo.issues.comment.blocked_user")) | ||||||
| @@ -3178,21 +3175,27 @@ func UpdateCommentContent(ctx *context.Context) { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	content, err := markdown.RenderString(&markup.RenderContext{ | 	var renderedContent template.HTML | ||||||
| 		Links: markup.Links{ | 	if comment.Content != "" { | ||||||
| 			Base: ctx.FormString("context"), // FIXME: <- IS THIS SAFE ? | 		renderedContent, err = markdown.RenderString(&markup.RenderContext{ | ||||||
| 		}, | 			Links: markup.Links{ | ||||||
| 		Metas:   ctx.Repo.Repository.ComposeMetas(ctx), | 				Base: ctx.FormString("context"), // FIXME: <- IS THIS SAFE ? | ||||||
| 		GitRepo: ctx.Repo.GitRepo, | 			}, | ||||||
| 		Ctx:     ctx, | 			Metas:   ctx.Repo.Repository.ComposeMetas(ctx), | ||||||
| 	}, comment.Content) | 			GitRepo: ctx.Repo.GitRepo, | ||||||
| 	if err != nil { | 			Ctx:     ctx, | ||||||
| 		ctx.ServerError("RenderString", err) | 		}, comment.Content) | ||||||
| 		return | 		if err != nil { | ||||||
|  | 			ctx.ServerError("RenderString", err) | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 	} else { | ||||||
|  | 		contentEmpty := fmt.Sprintf(`<span class="no-content">%s</span>`, ctx.Tr("repo.issues.no_content")) | ||||||
|  | 		renderedContent = template.HTML(contentEmpty) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	ctx.JSON(http.StatusOK, map[string]any{ | 	ctx.JSON(http.StatusOK, map[string]any{ | ||||||
| 		"content":     content, | 		"content":     renderedContent, | ||||||
| 		"attachments": attachmentsHTML(ctx, comment.Attachments, comment.Content), | 		"attachments": attachmentsHTML(ctx, comment.Attachments, comment.Content), | ||||||
| 	}) | 	}) | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user