@@ -478,6 +478,7 @@ func RegisterRoutes(m *macaron.Macaron) {
478
478
m .Get ("/following" , user .Following )
479
479
})
480
480
481
+ //Keeping this path to have backward compat
481
482
m .Get ("/attachments/:uuid" , func (ctx * context.Context ) {
482
483
attach , err := models .GetAttachmentByUUID (ctx .Params (":uuid" ))
483
484
if err != nil {
@@ -489,6 +490,38 @@ func RegisterRoutes(m *macaron.Macaron) {
489
490
return
490
491
}
491
492
493
+ //Attachement without issue or release attached should not be returned
494
+ if attach .IsNotAttached () {
495
+ ctx .Error (404 )
496
+ return
497
+ }
498
+ //Check issue access
499
+ if attach .IssueID != 0 {
500
+ iss , err = GetIssueByID (attach .IssueID )
501
+ if err != nil {{
502
+ ctx .ServerError ("GetAttachmentByUUID.GetIssueByID" , err )
503
+ return
504
+ }
505
+ if ! iss .Repo .CanRead (models .UnitTypeIssues ){
506
+ ctx .Error (403 )
507
+ return
508
+ }
509
+ }
510
+
511
+ //Check release access
512
+ if attach .ReleaseID != 0 {
513
+ rel , err = GetReleaseByID (attach .ReleaseID )
514
+ if err != nil {{
515
+ ctx .ServerError ("GetAttachmentByUUID.GetReleaseByID" , err )
516
+ return
517
+ }
518
+ if ! rel .Repo .CanRead (models .UnitTypeIssues ){
519
+ ctx .Error (403 )
520
+ return
521
+ }
522
+ }
523
+
524
+ //If we have matched a access release or issue
492
525
fr , err := os .Open (attach .LocalPath ())
493
526
if err != nil {
494
527
ctx .ServerError ("Open" , err )
@@ -675,6 +708,10 @@ func RegisterRoutes(m *macaron.Macaron) {
675
708
m .Combo ("/new" ).Get (context .RepoRef (), repo .NewIssue ).
676
709
Post (bindIgnErr (auth.CreateIssueForm {}), repo .NewIssuePost )
677
710
}, context .RepoMustNotBeArchived (), reqRepoIssueReader )
711
+
712
+ //Should be able to create issue (a user that can create release can create issue)
713
+ m .Post ("/attachments" , repo .UploadAttachment , context .RepoMustNotBeArchived (), reqRepoIssueReader )
714
+
678
715
// FIXME: should use different URLs but mostly same logic for comments of issue and pull reuqest.
679
716
// So they can apply their own enable/disable logic on routers.
680
717
m .Group ("/issues" , func () {
@@ -770,7 +807,6 @@ func RegisterRoutes(m *macaron.Macaron) {
770
807
m .Get ("/new" , repo .NewRelease )
771
808
m .Post ("/new" , bindIgnErr (auth.NewReleaseForm {}), repo .NewReleasePost )
772
809
m .Post ("/delete" , repo .DeleteRelease )
773
- m .Post ("/attachments" , repo .UploadAttachment )
774
810
}, reqSignIn , repo .MustBeNotEmpty , context .RepoMustNotBeArchived (), reqRepoReleaseWriter , context .RepoRef ())
775
811
m .Group ("/releases" , func () {
776
812
m .Get ("/edit/*" , repo .EditRelease )
0 commit comments