@@ -57,17 +57,15 @@ const (
57
57
issueTemplateTitleKey = "IssueTemplateTitle"
58
58
)
59
59
60
- var (
61
- // IssueTemplateCandidates issue templates
62
- IssueTemplateCandidates = []string {
63
- "ISSUE_TEMPLATE.md" ,
64
- "issue_template.md" ,
65
- ".gitea/ISSUE_TEMPLATE.md" ,
66
- ".gitea/issue_template.md" ,
67
- ".github/ISSUE_TEMPLATE.md" ,
68
- ".github/issue_template.md" ,
69
- }
70
- )
60
+ // IssueTemplateCandidates issue templates
61
+ var IssueTemplateCandidates = []string {
62
+ "ISSUE_TEMPLATE.md" ,
63
+ "issue_template.md" ,
64
+ ".gitea/ISSUE_TEMPLATE.md" ,
65
+ ".gitea/issue_template.md" ,
66
+ ".github/ISSUE_TEMPLATE.md" ,
67
+ ".github/issue_template.md" ,
68
+ }
71
69
72
70
// MustAllowUserComment checks to make sure if an issue is locked.
73
71
// If locked and user has permissions to write to the repository,
@@ -245,7 +243,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
245
243
}
246
244
}
247
245
248
- var issueList = models .IssueList (issues )
246
+ issueList : = models .IssueList (issues )
249
247
approvalCounts , err := issueList .GetApprovalCounts ()
250
248
if err != nil {
251
249
ctx .ServerError ("ApprovalCounts" , err )
@@ -311,8 +309,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
311
309
assigneeID = 0 // Reset ID to prevent unexpected selection of assignee.
312
310
}
313
311
314
- ctx .Data ["IssueRefEndNames" ], ctx .Data ["IssueRefURLs" ] =
315
- issue_service .GetRefEndNamesAndURLs (issues , ctx .Repo .RepoLink )
312
+ ctx .Data ["IssueRefEndNames" ], ctx .Data ["IssueRefURLs" ] = issue_service .GetRefEndNamesAndURLs (issues , ctx .Repo .RepoLink )
316
313
317
314
ctx .Data ["ApprovalCounts" ] = func (issueID int64 , typ string ) int64 {
318
315
counts , ok := approvalCounts [issueID ]
@@ -442,7 +439,6 @@ func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *repo_model.R
442
439
}
443
440
444
441
func retrieveProjects (ctx * context.Context , repo * repo_model.Repository ) {
445
-
446
442
var err error
447
443
448
444
ctx .Data ["OpenProjects" ], _ , err = models .GetProjects (models.ProjectSearchOptions {
@@ -796,7 +792,8 @@ func NewIssue(ctx *context.Context) {
796
792
body := ctx .FormString ("body" )
797
793
ctx .Data ["BodyQuery" ] = body
798
794
799
- ctx .Data ["IsProjectsEnabled" ] = ctx .Repo .CanRead (unit .TypeProjects )
795
+ isProjectsEnabled := ctx .Repo .CanRead (unit .TypeProjects )
796
+ ctx .Data ["IsProjectsEnabled" ] = isProjectsEnabled
800
797
ctx .Data ["IsAttachmentEnabled" ] = setting .Attachment .Enabled
801
798
upload .AddUploadContext (ctx , "comment" )
802
799
@@ -812,7 +809,7 @@ func NewIssue(ctx *context.Context) {
812
809
}
813
810
814
811
projectID := ctx .FormInt64 ("project" )
815
- if projectID > 0 {
812
+ if projectID > 0 && isProjectsEnabled {
816
813
project , err := models .GetProjectByID (projectID )
817
814
if err != nil {
818
815
log .Error ("GetProjectByID: %d: %v" , projectID , err )
@@ -1017,6 +1014,12 @@ func NewIssuePost(ctx *context.Context) {
1017
1014
}
1018
1015
1019
1016
if projectID > 0 {
1017
+ if ! ctx .Repo .CanRead (unit .TypeProjects ) {
1018
+ // User must also be able to see the project.
1019
+ ctx .Error (http .StatusBadRequest , "user hasn't permissions to read projects" )
1020
+ return
1021
+ }
1022
+
1020
1023
if err := models .ChangeProjectAssign (issue , ctx .User , projectID ); err != nil {
1021
1024
ctx .ServerError ("ChangeProjectAssign" , err )
1022
1025
return
@@ -1713,6 +1716,11 @@ func getActionIssues(ctx *context.Context) []*models.Issue {
1713
1716
issueUnitEnabled := ctx .Repo .CanRead (unit .TypeIssues )
1714
1717
prUnitEnabled := ctx .Repo .CanRead (unit .TypePullRequests )
1715
1718
for _ , issue := range issues {
1719
+ if issue .RepoID != ctx .Repo .Repository .ID {
1720
+ ctx .NotFound ("some issue's RepoID is incorrect" , errors .New ("some issue's RepoID is incorrect" ))
1721
+ return nil
1722
+ }
1723
+
1716
1724
if issue .IsPull && ! prUnitEnabled || ! issue .IsPull && ! issueUnitEnabled {
1717
1725
ctx .NotFound ("IssueOrPullRequestUnitNotAllowed" , nil )
1718
1726
return nil
@@ -2515,7 +2523,7 @@ func filterXRefComments(ctx *context.Context, issue *models.Issue) error {
2515
2523
// GetIssueAttachments returns attachments for the issue
2516
2524
func GetIssueAttachments (ctx * context.Context ) {
2517
2525
issue := GetActionIssue (ctx )
2518
- var attachments = make ([]* api.Attachment , len (issue .Attachments ))
2526
+ attachments : = make ([]* api.Attachment , len (issue .Attachments ))
2519
2527
for i := 0 ; i < len (issue .Attachments ); i ++ {
2520
2528
attachments [i ] = convert .ToReleaseAttachment (issue .Attachments [i ])
2521
2529
}
@@ -2529,7 +2537,7 @@ func GetCommentAttachments(ctx *context.Context) {
2529
2537
ctx .NotFoundOrServerError ("GetCommentByID" , models .IsErrCommentNotExist , err )
2530
2538
return
2531
2539
}
2532
- var attachments = make ([]* api.Attachment , 0 )
2540
+ attachments : = make ([]* api.Attachment , 0 )
2533
2541
if comment .Type == models .CommentTypeComment {
2534
2542
if err := comment .LoadAttachments (); err != nil {
2535
2543
ctx .ServerError ("LoadAttachments" , err )
@@ -2674,7 +2682,7 @@ func handleTeamMentions(ctx *context.Context) {
2674
2682
var isAdmin bool
2675
2683
var err error
2676
2684
var teams []* models.Team
2677
- var org = models .OrgFromUser (ctx .Repo .Owner )
2685
+ org : = models .OrgFromUser (ctx .Repo .Owner )
2678
2686
// Admin has super access.
2679
2687
if ctx .User .IsAdmin {
2680
2688
isAdmin = true
0 commit comments