@@ -57,17 +57,15 @@ const (
5757 issueTemplateTitleKey = "IssueTemplateTitle"
5858)
5959
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+ }
7169
7270// MustAllowUserComment checks to make sure if an issue is locked.
7371// 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
245243 }
246244 }
247245
248- var issueList = models .IssueList (issues )
246+ issueList : = models .IssueList (issues )
249247 approvalCounts , err := issueList .GetApprovalCounts ()
250248 if err != nil {
251249 ctx .ServerError ("ApprovalCounts" , err )
@@ -311,8 +309,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
311309 assigneeID = 0 // Reset ID to prevent unexpected selection of assignee.
312310 }
313311
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 )
316313
317314 ctx .Data ["ApprovalCounts" ] = func (issueID int64 , typ string ) int64 {
318315 counts , ok := approvalCounts [issueID ]
@@ -442,7 +439,6 @@ func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *repo_model.R
442439}
443440
444441func retrieveProjects (ctx * context.Context , repo * repo_model.Repository ) {
445-
446442 var err error
447443
448444 ctx .Data ["OpenProjects" ], _ , err = models .GetProjects (models.ProjectSearchOptions {
@@ -796,7 +792,8 @@ func NewIssue(ctx *context.Context) {
796792 body := ctx .FormString ("body" )
797793 ctx .Data ["BodyQuery" ] = body
798794
799- ctx .Data ["IsProjectsEnabled" ] = ctx .Repo .CanRead (unit .TypeProjects )
795+ isProjectsEnabled := ctx .Repo .CanRead (unit .TypeProjects )
796+ ctx .Data ["IsProjectsEnabled" ] = isProjectsEnabled
800797 ctx .Data ["IsAttachmentEnabled" ] = setting .Attachment .Enabled
801798 upload .AddUploadContext (ctx , "comment" )
802799
@@ -812,7 +809,7 @@ func NewIssue(ctx *context.Context) {
812809 }
813810
814811 projectID := ctx .FormInt64 ("project" )
815- if projectID > 0 {
812+ if projectID > 0 && isProjectsEnabled {
816813 project , err := models .GetProjectByID (projectID )
817814 if err != nil {
818815 log .Error ("GetProjectByID: %d: %v" , projectID , err )
@@ -1017,6 +1014,12 @@ func NewIssuePost(ctx *context.Context) {
10171014 }
10181015
10191016 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+
10201023 if err := models .ChangeProjectAssign (issue , ctx .User , projectID ); err != nil {
10211024 ctx .ServerError ("ChangeProjectAssign" , err )
10221025 return
@@ -1713,6 +1716,11 @@ func getActionIssues(ctx *context.Context) []*models.Issue {
17131716 issueUnitEnabled := ctx .Repo .CanRead (unit .TypeIssues )
17141717 prUnitEnabled := ctx .Repo .CanRead (unit .TypePullRequests )
17151718 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+
17161724 if issue .IsPull && ! prUnitEnabled || ! issue .IsPull && ! issueUnitEnabled {
17171725 ctx .NotFound ("IssueOrPullRequestUnitNotAllowed" , nil )
17181726 return nil
@@ -2515,7 +2523,7 @@ func filterXRefComments(ctx *context.Context, issue *models.Issue) error {
25152523// GetIssueAttachments returns attachments for the issue
25162524func GetIssueAttachments (ctx * context.Context ) {
25172525 issue := GetActionIssue (ctx )
2518- var attachments = make ([]* api.Attachment , len (issue .Attachments ))
2526+ attachments : = make ([]* api.Attachment , len (issue .Attachments ))
25192527 for i := 0 ; i < len (issue .Attachments ); i ++ {
25202528 attachments [i ] = convert .ToReleaseAttachment (issue .Attachments [i ])
25212529 }
@@ -2529,7 +2537,7 @@ func GetCommentAttachments(ctx *context.Context) {
25292537 ctx .NotFoundOrServerError ("GetCommentByID" , models .IsErrCommentNotExist , err )
25302538 return
25312539 }
2532- var attachments = make ([]* api.Attachment , 0 )
2540+ attachments : = make ([]* api.Attachment , 0 )
25332541 if comment .Type == models .CommentTypeComment {
25342542 if err := comment .LoadAttachments (); err != nil {
25352543 ctx .ServerError ("LoadAttachments" , err )
@@ -2674,7 +2682,7 @@ func handleTeamMentions(ctx *context.Context) {
26742682 var isAdmin bool
26752683 var err error
26762684 var teams []* models.Team
2677- var org = models .OrgFromUser (ctx .Repo .Owner )
2685+ org : = models .OrgFromUser (ctx .Repo .Owner )
26782686 // Admin has super access.
26792687 if ctx .User .IsAdmin {
26802688 isAdmin = true
0 commit comments