Skip to content

Commit 48f5d51

Browse files
a1012112796delvhlunny
authored
fix permission check for creating comment while mail (#22524)
only creating comment on locked issue request write permission, for others, read permission is enough. related to #22056 /cc @KN4CK3R --------- Signed-off-by: a1012112796 <[email protected]> Co-authored-by: delvh <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
1 parent 95d9fbd commit 48f5d51

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: services/mailer/incoming/incoming_handler.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,17 @@ func (h *ReplyHandler) Handle(ctx context.Context, content *MailContent, doer *u
7171
return err
7272
}
7373

74-
if !perm.CanWriteIssuesOrPulls(issue.IsPull) || issue.IsLocked && !doer.IsAdmin {
74+
// Locked issues require write permissions
75+
if issue.IsLocked && !perm.CanWriteIssuesOrPulls(issue.IsPull) && !doer.IsAdmin {
7576
log.Debug("can't write issue or pull")
7677
return nil
7778
}
7879

80+
if !perm.CanReadIssuesOrPulls(issue.IsPull) {
81+
log.Debug("can't read issue or pull")
82+
return nil
83+
}
84+
7985
switch r := ref.(type) {
8086
case *issues_model.Issue:
8187
attachmentIDs := make([]string, 0, len(content.Attachments))

0 commit comments

Comments
 (0)