@@ -3149,13 +3149,10 @@ func UpdateCommentContent(ctx *context.Context) {
3149
3149
}
3150
3150
3151
3151
oldContent := comment .Content
3152
- comment .Content = ctx .FormString ("content" )
3153
- if len (comment .Content ) == 0 {
3154
- ctx .JSON (http .StatusOK , map [string ]any {
3155
- "content" : "" ,
3156
- })
3157
- return
3158
- }
3152
+ newContent := ctx .FormString ("content" )
3153
+
3154
+ // allow to save empty content
3155
+ comment .Content = newContent
3159
3156
if err = issue_service .UpdateComment (ctx , comment , ctx .Doer , oldContent ); err != nil {
3160
3157
if errors .Is (err , user_model .ErrBlockedUser ) {
3161
3158
ctx .JSONError (ctx .Tr ("repo.issues.comment.blocked_user" ))
@@ -3178,21 +3175,27 @@ func UpdateCommentContent(ctx *context.Context) {
3178
3175
}
3179
3176
}
3180
3177
3181
- content , err := markdown .RenderString (& markup.RenderContext {
3182
- Links : markup.Links {
3183
- Base : ctx .FormString ("context" ), // FIXME: <- IS THIS SAFE ?
3184
- },
3185
- Metas : ctx .Repo .Repository .ComposeMetas (ctx ),
3186
- GitRepo : ctx .Repo .GitRepo ,
3187
- Ctx : ctx ,
3188
- }, comment .Content )
3189
- if err != nil {
3190
- ctx .ServerError ("RenderString" , err )
3191
- return
3178
+ var renderedContent template.HTML
3179
+ if comment .Content != "" {
3180
+ renderedContent , err = markdown .RenderString (& markup.RenderContext {
3181
+ Links : markup.Links {
3182
+ Base : ctx .FormString ("context" ), // FIXME: <- IS THIS SAFE ?
3183
+ },
3184
+ Metas : ctx .Repo .Repository .ComposeMetas (ctx ),
3185
+ GitRepo : ctx .Repo .GitRepo ,
3186
+ Ctx : ctx ,
3187
+ }, comment .Content )
3188
+ if err != nil {
3189
+ ctx .ServerError ("RenderString" , err )
3190
+ return
3191
+ }
3192
+ } else {
3193
+ contentEmpty := fmt .Sprintf (`<span class="no-content">%s</span>` , ctx .Tr ("repo.issues.no_content" ))
3194
+ renderedContent = template .HTML (contentEmpty )
3192
3195
}
3193
3196
3194
3197
ctx .JSON (http .StatusOK , map [string ]any {
3195
- "content" : content ,
3198
+ "content" : renderedContent ,
3196
3199
"attachments" : attachmentsHTML (ctx , comment .Attachments , comment .Content ),
3197
3200
})
3198
3201
}
0 commit comments