mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Fix internal server error when updating labels without write permission (#32776)
Fix #32775 if permission denined, `prepareForReplaceOrAdd` will return nothing, and this case is not handled.
This commit is contained in:
		| @@ -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 | ||||
| @@ -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 | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user