@@ -188,9 +188,13 @@ func Milestones(ctx *context.Context) {
188188 ctx .ServerError ("env.RepoIDs" , err )
189189 return
190190 }
191+ userRepoIDs , err = models .FilterOutRepoIdsWithoutUnitAccess (ctx .User , userRepoIDs , models .UnitTypeIssues , models .UnitTypePullRequests )
192+ if err != nil {
193+ ctx .ServerError ("FilterOutRepoIdsWithoutUnitAccess" , err )
194+ return
195+ }
191196 } else {
192- unitType := models .UnitTypeIssues
193- userRepoIDs , err = ctxUser .GetAccessRepoIDs (unitType )
197+ userRepoIDs , err = ctxUser .GetAccessRepoIDs (models .UnitTypeIssues , models .UnitTypePullRequests )
194198 if err != nil {
195199 ctx .ServerError ("ctxUser.GetAccessRepoIDs" , err )
196200 return
@@ -201,27 +205,30 @@ func Milestones(ctx *context.Context) {
201205 }
202206
203207 var repoIDs []int64
204- if issueReposQueryPattern .MatchString (reposQuery ) {
205- // remove "[" and "]" from string
206- reposQuery = reposQuery [1 : len (reposQuery )- 1 ]
207- //for each ID (delimiter ",") add to int to repoIDs
208- reposSet := false
209- for _ , rID := range strings .Split (reposQuery , "," ) {
210- // Ensure nonempty string entries
211- if rID != "" && rID != "0" {
212- reposSet = true
213- rIDint64 , err := strconv .ParseInt (rID , 10 , 64 )
214- if err == nil && com .IsSliceContainsInt64 (userRepoIDs , rIDint64 ) {
215- repoIDs = append (repoIDs , rIDint64 )
208+ if len (reposQuery ) != 0 {
209+ if issueReposQueryPattern .MatchString (reposQuery ) {
210+ // remove "[" and "]" from string
211+ reposQuery = reposQuery [1 : len (reposQuery )- 1 ]
212+ //for each ID (delimiter ",") add to int to repoIDs
213+ reposSet := false
214+ for _ , rID := range strings .Split (reposQuery , "," ) {
215+ // Ensure nonempty string entries
216+ if rID != "" && rID != "0" {
217+ reposSet = true
218+ rIDint64 , err := strconv .ParseInt (rID , 10 , 64 )
219+ // If the repo id specified by query is not parseable or not accessible by user, just ignore it.
220+ if err == nil && com .IsSliceContainsInt64 (userRepoIDs , rIDint64 ) {
221+ repoIDs = append (repoIDs , rIDint64 )
222+ }
216223 }
217224 }
225+ if reposSet && len (repoIDs ) == 0 {
226+ // force an empty result
227+ repoIDs = []int64 {- 1 }
228+ }
229+ } else {
230+ log .Warn ("issueReposQueryPattern not match with query" )
218231 }
219- if reposSet && len (repoIDs ) == 0 {
220- // force an empty result
221- repoIDs = []int64 {- 1 }
222- }
223- } else {
224- log .Error ("issueReposQueryPattern not match with query" )
225232 }
226233
227234 if len (repoIDs ) == 0 {
@@ -256,26 +263,6 @@ func Milestones(ctx *context.Context) {
256263 }
257264 }
258265 showReposMap [rID ] = repo
259-
260- // Check if user has access to given repository.
261- perm , err := models .GetUserRepoPermission (repo , ctxUser )
262- if err != nil {
263- ctx .ServerError ("GetUserRepoPermission" , fmt .Errorf ("[%d]%v" , rID , err ))
264- return
265- }
266-
267- if ! perm .CanRead (models .UnitTypeIssues ) {
268- if log .IsTrace () {
269- log .Trace ("Permission Denied: User %-v cannot read %-v of repo %-v\n " +
270- "User in repo has Permissions: %-+v" ,
271- ctxUser ,
272- models .UnitTypeIssues ,
273- repo ,
274- perm )
275- }
276- ctx .Status (404 )
277- return
278- }
279266 }
280267
281268 showRepos := models .RepositoryListOfMap (showReposMap )
@@ -345,9 +332,11 @@ var issueReposQueryPattern = regexp.MustCompile(`^\[\d+(,\d+)*,?\]$`)
345332// Issues render the user issues page
346333func Issues (ctx * context.Context ) {
347334 isPullList := ctx .Params (":type" ) == "pulls"
335+ unitType := models .UnitTypeIssues
348336 if isPullList {
349337 ctx .Data ["Title" ] = ctx .Tr ("pull_requests" )
350338 ctx .Data ["PageIsPulls" ] = true
339+ unitType = models .UnitTypePullRequests
351340 } else {
352341 ctx .Data ["Title" ] = ctx .Tr ("issues" )
353342 ctx .Data ["PageIsIssues" ] = true
@@ -404,7 +393,7 @@ func Issues(ctx *context.Context) {
404393 }
405394 }
406395 } else {
407- log .Error ("issueReposQueryPattern not match with query" )
396+ log .Warn ("issueReposQueryPattern not match with query" )
408397 }
409398 }
410399
@@ -424,11 +413,12 @@ func Issues(ctx *context.Context) {
424413 ctx .ServerError ("env.RepoIDs" , err )
425414 return
426415 }
427- } else {
428- unitType := models . UnitTypeIssues
429- if isPullList {
430- unitType = models . UnitTypePullRequests
416+ userRepoIDs , err = models . FilterOutRepoIdsWithoutUnitAccess ( ctx . User , userRepoIDs , unitType )
417+ if err != nil {
418+ ctx . ServerError ( "FilterOutRepoIdsWithoutUnitAccess" , err )
419+ return
431420 }
421+ } else {
432422 userRepoIDs , err = ctxUser .GetAccessRepoIDs (unitType )
433423 if err != nil {
434424 ctx .ServerError ("ctxUser.GetAccessRepoIDs" , err )
0 commit comments