Commit e17593e7 authored by Sander van Harmelen's avatar Sander van Harmelen

Properly path escape branch and sha parts of the URL

parent 3def0345
language: go
go:
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x
......
......@@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/url"
"time"
)
......@@ -150,7 +151,7 @@ func (s *CommitsService) GetCommitRefs(pid interface{}, sha string, opt *GetComm
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/refs", pathEscape(project), sha)
u := fmt.Sprintf("projects/%s/repository/commits/%s/refs", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, opt, options)
if err != nil {
......@@ -175,7 +176,7 @@ func (s *CommitsService) GetCommit(pid interface{}, sha string, options ...Optio
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/commits/%s", pathEscape(project), sha)
u := fmt.Sprintf("projects/%s/repository/commits/%s", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, nil, options)
if err != nil {
......@@ -260,7 +261,7 @@ func (s *CommitsService) GetCommitDiff(pid interface{}, sha string, opt *GetComm
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/diff", pathEscape(project), sha)
u := fmt.Sprintf("projects/%s/repository/commits/%s/diff", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, opt, options)
if err != nil {
......@@ -317,7 +318,7 @@ func (s *CommitsService) GetCommitComments(pid interface{}, sha string, opt *Get
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/comments", pathEscape(project), sha)
u := fmt.Sprintf("projects/%s/repository/commits/%s/comments", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, opt, options)
if err != nil {
......@@ -356,7 +357,7 @@ func (s *CommitsService) PostCommitComment(pid interface{}, sha string, opt *Pos
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/comments", pathEscape(project), sha)
u := fmt.Sprintf("projects/%s/repository/commits/%s/comments", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("POST", u, opt, options)
if err != nil {
......@@ -408,7 +409,7 @@ func (s *CommitsService) GetCommitStatuses(pid interface{}, sha string, opt *Get
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/statuses", pathEscape(project), sha)
u := fmt.Sprintf("projects/%s/repository/commits/%s/statuses", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, opt, options)
if err != nil {
......@@ -444,7 +445,7 @@ func (s *CommitsService) SetCommitStatus(pid interface{}, sha string, opt *SetCo
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/statuses/%s", pathEscape(project), sha)
u := fmt.Sprintf("projects/%s/statuses/%s", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("POST", u, opt, options)
if err != nil {
......@@ -469,7 +470,7 @@ func (s *CommitsService) GetMergeRequestsByCommit(pid interface{}, sha string, o
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/merge_requests", pathEscape(project), sha)
u := fmt.Sprintf("projects/%s/repository/commits/%s/merge_requests", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, nil, options)
if err != nil {
......@@ -500,7 +501,7 @@ func (s *CommitsService) CherryPickCommit(pid interface{}, sha string, opt *Cher
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/cherry_pick", pathEscape(project), sha)
u := fmt.Sprintf("projects/%s/repository/commits/%s/cherry_pick", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("POST", u, opt, options)
if err != nil {
......@@ -531,7 +532,7 @@ func (s *CommitsService) RevertCommit(pid interface{}, sha string, opt *RevertCo
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/revert", pathEscape(project), sha)
u := fmt.Sprintf("projects/%s/repository/commits/%s/revert", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("POST", u, opt, options)
if err != nil {
......@@ -568,7 +569,7 @@ func (s *CommitsService) GetGPGSiganature(pid interface{}, sha string, options .
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/commits/%s/signature", pathEscape(project), sha)
u := fmt.Sprintf("projects/%s/repository/commits/%s/signature", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, nil, options)
if err != nil {
......
......@@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/url"
)
// ProtectedBranchesService handles communication with the protected branch
......@@ -90,7 +91,7 @@ func (s *ProtectedBranchesService) GetProtectedBranch(pid interface{}, branch st
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/protected_branches/%s", pathEscape(project), branch)
u := fmt.Sprintf("projects/%s/protected_branches/%s", pathEscape(project), url.PathEscape(branch))
req, err := s.client.NewRequest("GET", u, nil, options)
if err != nil {
......@@ -153,7 +154,7 @@ func (s *ProtectedBranchesService) UnprotectRepositoryBranches(pid interface{},
if err != nil {
return nil, err
}
u := fmt.Sprintf("projects/%s/protected_branches/%s", pathEscape(project), branch)
u := fmt.Sprintf("projects/%s/protected_branches/%s", pathEscape(project), url.PathEscape(branch))
req, err := s.client.NewRequest("DELETE", u, nil, options)
if err != nil {
......
......@@ -20,6 +20,7 @@ import (
"bytes"
"fmt"
"io"
"net/url"
)
// RepositoriesService handles communication with the repositories related
......@@ -91,7 +92,7 @@ func (s *RepositoriesService) Blob(pid interface{}, sha string, options ...Optio
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/blobs/%s", pathEscape(project), sha)
u := fmt.Sprintf("projects/%s/repository/blobs/%s", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, nil, options)
if err != nil {
......@@ -116,7 +117,7 @@ func (s *RepositoriesService) RawBlobContent(pid interface{}, sha string, option
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/blobs/%s/raw", pathEscape(project), sha)
u := fmt.Sprintf("projects/%s/repository/blobs/%s/raw", pathEscape(project), url.PathEscape(sha))
req, err := s.client.NewRequest("GET", u, nil, options)
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment