@@ -188,9 +188,13 @@ func Milestones(ctx *context.Context) {
188
188
ctx .ServerError ("env.RepoIDs" , err )
189
189
return
190
190
}
191
+ userRepoIDs , err = models .FilterOutRepoIdsWithoutUnitAccess (ctx .User , userRepoIDs , models .UnitTypeIssues , models .UnitTypePullRequests )
192
+ if err != nil {
193
+ ctx .ServerError ("FilterOutRepoIdsWithoutUnitAccess" , err )
194
+ return
195
+ }
191
196
} else {
192
- unitType := models .UnitTypeIssues
193
- userRepoIDs , err = ctxUser .GetAccessRepoIDs (unitType )
197
+ userRepoIDs , err = ctxUser .GetAccessRepoIDs (models .UnitTypeIssues , models .UnitTypePullRequests )
194
198
if err != nil {
195
199
ctx .ServerError ("ctxUser.GetAccessRepoIDs" , err )
196
200
return
@@ -201,27 +205,30 @@ func Milestones(ctx *context.Context) {
201
205
}
202
206
203
207
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
+ }
216
223
}
217
224
}
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" )
218
231
}
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" )
225
232
}
226
233
227
234
if len (repoIDs ) == 0 {
@@ -256,26 +263,6 @@ func Milestones(ctx *context.Context) {
256
263
}
257
264
}
258
265
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
- }
279
266
}
280
267
281
268
showRepos := models .RepositoryListOfMap (showReposMap )
@@ -345,9 +332,11 @@ var issueReposQueryPattern = regexp.MustCompile(`^\[\d+(,\d+)*,?\]$`)
345
332
// Issues render the user issues page
346
333
func Issues (ctx * context.Context ) {
347
334
isPullList := ctx .Params (":type" ) == "pulls"
335
+ unitType := models .UnitTypeIssues
348
336
if isPullList {
349
337
ctx .Data ["Title" ] = ctx .Tr ("pull_requests" )
350
338
ctx .Data ["PageIsPulls" ] = true
339
+ unitType = models .UnitTypePullRequests
351
340
} else {
352
341
ctx .Data ["Title" ] = ctx .Tr ("issues" )
353
342
ctx .Data ["PageIsIssues" ] = true
@@ -404,7 +393,7 @@ func Issues(ctx *context.Context) {
404
393
}
405
394
}
406
395
} else {
407
- log .Error ("issueReposQueryPattern not match with query" )
396
+ log .Warn ("issueReposQueryPattern not match with query" )
408
397
}
409
398
}
410
399
@@ -424,11 +413,12 @@ func Issues(ctx *context.Context) {
424
413
ctx .ServerError ("env.RepoIDs" , err )
425
414
return
426
415
}
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
431
420
}
421
+ } else {
432
422
userRepoIDs , err = ctxUser .GetAccessRepoIDs (unitType )
433
423
if err != nil {
434
424
ctx .ServerError ("ctxUser.GetAccessRepoIDs" , err )
0 commit comments