mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 03:18:24 +00:00 
			
		
		
		
	backport #28213 This PR will fix some missed checks for private repositories' data on web routes and API routes.
This commit is contained in:
		| @@ -3091,6 +3091,11 @@ func UpdateCommentContent(ctx *context.Context) { | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if comment.Issue.RepoID != ctx.Repo.Repository.ID { | ||||
| 		ctx.NotFound("CompareRepoID", issues_model.ErrCommentNotExist{}) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if !ctx.IsSigned || (ctx.Doer.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) { | ||||
| 		ctx.Error(http.StatusForbidden) | ||||
| 		return | ||||
| @@ -3157,6 +3162,11 @@ func DeleteComment(ctx *context.Context) { | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if comment.Issue.RepoID != ctx.Repo.Repository.ID { | ||||
| 		ctx.NotFound("CompareRepoID", issues_model.ErrCommentNotExist{}) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if !ctx.IsSigned || (ctx.Doer.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) { | ||||
| 		ctx.Error(http.StatusForbidden) | ||||
| 		return | ||||
| @@ -3283,6 +3293,11 @@ func ChangeCommentReaction(ctx *context.Context) { | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if comment.Issue.RepoID != ctx.Repo.Repository.ID { | ||||
| 		ctx.NotFound("CompareRepoID", issues_model.ErrCommentNotExist{}) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if !ctx.IsSigned || (ctx.Doer.ID != comment.PosterID && !ctx.Repo.CanReadIssuesOrPulls(comment.Issue.IsPull)) { | ||||
| 		if log.IsTrace() { | ||||
| 			if ctx.IsSigned { | ||||
| @@ -3426,6 +3441,21 @@ func GetCommentAttachments(ctx *context.Context) { | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if err := comment.LoadIssue(ctx); err != nil { | ||||
| 		ctx.NotFoundOrServerError("LoadIssue", issues_model.IsErrIssueNotExist, err) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if comment.Issue.RepoID != ctx.Repo.Repository.ID { | ||||
| 		ctx.NotFound("CompareRepoID", issues_model.ErrCommentNotExist{}) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if !ctx.Repo.Permission.CanReadIssuesOrPulls(comment.Issue.IsPull) { | ||||
| 		ctx.NotFound("CanReadIssuesOrPulls", issues_model.ErrCommentNotExist{}) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if !comment.Type.HasAttachmentSupport() { | ||||
| 		ctx.ServerError("GetCommentAttachments", fmt.Errorf("comment type %v does not support attachments", comment.Type)) | ||||
| 		return | ||||
|   | ||||
		Reference in New Issue
	
	Block a user