Skip to content

Commit

Permalink
Fix internal server error when updating labels without write permissi…
Browse files Browse the repository at this point in the history
…on (go-gitea#32776)

Fix go-gitea#32775

if permission denined, `prepareForReplaceOrAdd` will return nothing, and
this case is not handled.
  • Loading branch information
yp05327 authored and GiteaBot committed Dec 10, 2024
1 parent 3a9039b commit f12945a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions routers/api/v1/repo/issue_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ func prepareForReplaceOrAdd(ctx *context.APIContext, form api.IssueLabelsOption)
return nil, nil, err
}

if !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) {
ctx.Error(http.StatusForbidden, "CanWriteIssuesOrPulls", "write permission is required")
return nil, nil, fmt.Errorf("permission denied")
}

var (
labelIDs []int64
labelNames []string
Expand Down Expand Up @@ -350,10 +355,5 @@ func prepareForReplaceOrAdd(ctx *context.APIContext, form api.IssueLabelsOption)
return nil, nil, err
}

if !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) {
ctx.Status(http.StatusForbidden)
return nil, nil, nil
}

return issue, labels, err
}

0 comments on commit f12945a

Please sign in to comment.