Skip to content

Commit cd2dd5a

Browse files
GiteaBotlunny
andauthored
Fix missing check (#28406) (#28411)
Backport #28406 by @lunny Co-authored-by: Lunny Xiao <[email protected]>
1 parent 46beb7f commit cd2dd5a

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

routers/web/repo/issue_content_history.go

+18-4
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,29 @@ func SoftDeleteContentHistory(ctx *context.Context) {
193193
var comment *issues_model.Comment
194194
var history *issues_model.ContentHistory
195195
var err error
196+
197+
if history, err = issues_model.GetIssueContentHistoryByID(ctx, historyID); err != nil {
198+
log.Error("can not get issue content history %v. err=%v", historyID, err)
199+
return
200+
}
201+
if history.IssueID != issue.ID {
202+
ctx.NotFound("CompareRepoID", issues_model.ErrCommentNotExist{})
203+
return
204+
}
196205
if commentID != 0 {
206+
if history.CommentID != commentID {
207+
ctx.NotFound("CompareCommentID", issues_model.ErrCommentNotExist{})
208+
return
209+
}
210+
197211
if comment, err = issues_model.GetCommentByID(ctx, commentID); err != nil {
198212
log.Error("can not get comment for issue content history %v. err=%v", historyID, err)
199213
return
200214
}
201-
}
202-
if history, err = issues_model.GetIssueContentHistoryByID(ctx, historyID); err != nil {
203-
log.Error("can not get issue content history %v. err=%v", historyID, err)
204-
return
215+
if comment.IssueID != issue.ID {
216+
ctx.NotFound("CompareIssueID", issues_model.ErrCommentNotExist{})
217+
return
218+
}
205219
}
206220

207221
canSoftDelete := canSoftDeleteContentHistory(ctx, issue, comment, history)

routers/web/repo/issue_pin.go

+6
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ func IssuePinMove(ctx *context.Context) {
9090
return
9191
}
9292

93+
if issue.RepoID != ctx.Repo.Repository.ID {
94+
ctx.Status(http.StatusNotFound)
95+
log.Error("Issue does not belong to this repository")
96+
return
97+
}
98+
9399
err = issue.MovePin(ctx, form.Position)
94100
if err != nil {
95101
ctx.Status(http.StatusInternalServerError)

0 commit comments

Comments
 (0)