Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

修复最佳评论越权问题

liqiang4661d9bf34d3f9
diff --git a/internal/service/content/answer_service.go b/internal/service/content/answer_service.go
index f904b82f..d3aab20b 100644
--- a/internal/service/content/answer_service.go
+++ b/internal/service/content/answer_service.go
@@ -455,6 +455,11 @@ func (as *AnswerService) AcceptAnswer(ctx context.Context, req *schema.AcceptAns
if !exist {
return errors.BadRequest(reason.AnswerNotFound)
}
+
+ // check answer belong to question
+ if acceptedAnswerInfo.QuestionID != req.QuestionID {
+ return errors.BadRequest(reason.AnswerNotFound)
+ }
acceptedAnswerInfo.ID = uid.DeShortID(acceptedAnswerInfo.ID)
}