UrlEscape Function Arguments used in UrlPath #273
No reviewers
Labels
No Label
has/backport
has/pull
in progress
invalid
kind/breaking
kind/bug
kind/build
kind/deployment
kind/docs
kind/enhancement
kind/feature
kind/lint
kind/proposal
kind/question
kind/refactor
kind/security
kind/testing
kind/translation
kind/ui
need/backport
priority/critical
priority/low
priority/maybe
priority/medium
reviewed/duplicate
reviewed/invalid
reviewed/wontfix
skip-changelog
status/blocked
status/needs-feedback
status/needs-reviews
status/wip
upstream/gitea
No Milestone
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: gitea/go-sdk#273
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "6543/go-sdk:EscapeUserRepoNames"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
close #271
6543 referenced this pull request2020-02-08 15:23:41 +00:00
extracted fix to #276
@ -33,3 +34,3 @@
func (c *Client) GetRepoGitHook(user, repo, id string) (*GitHook, error) {
h := new(GitHook)
return h, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/git/%s", user, repo, id), nil, nil, h)
return h, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/git/%s", url.PathEscape(user), url.PathEscape(repo), id), nil, nil, h)
If
id
is passed in to the library as an option it also needs to bePathEscape
'dIf
id
is passed in to the library as an option it also needs to bePathEscape
'd@ -24,3 +25,3 @@
return err
}
status, err := c.getStatusCode("PUT", fmt.Sprintf("/repos/%s/%s/issues/%d/subscriptions/%s", owner, repo, index, user), nil, nil)
status, err := c.getStatusCode("PUT", fmt.Sprintf("/repos/%s/%s/issues/%d/subscriptions/%s", url.PathEscape(owner), url.PathEscape(repo), index, user), nil, nil)
user
here probably needsPathEscape
too.@ -29,3 +30,3 @@
func (c *Client) GetUserTrackedTimes(owner, repo, user string) ([]*TrackedTime, error) {
times := make([]*TrackedTime, 0, 10)
return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times/%s", owner, repo, user), nil, nil, ×)
return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times/%s", url.PathEscape(owner), url.PathEscape(repo), user), nil, nil, ×)
user
here probably needsPathEscape
user
here probably needsPathEscape
@ -21,3 +22,3 @@
func (c *Client) GetBlob(user, repo, sha string) (*GitBlobResponse, error) {
blob := new(GitBlobResponse)
return blob, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/blobs/%s", user, repo, sha), nil, nil, blob)
return blob, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/blobs/%s", url.PathEscape(user), url.PathEscape(repo), sha), nil, nil, blob)
sha
should probably bePathEscape
d too.@ -47,3 +48,3 @@
func (c *Client) GetOrgHook(org string, id int64) (*Hook, error) {
h := new(Hook)
return h, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks/%d", org, id), nil, nil, h)
return h, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks/%d", url.PathEscape(org), id), nil, nil, h)
If
id
is passed in to the library as an option it also needs to bePathEscape
'did is an integer
@ -28,2 +29,2 @@
func (c *Client) IsCollaborator(user, repo, collaborator string) (bool, error) {
status, err := c.getStatusCode("GET", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, nil)
func (c *Client) IsCollaborator(owner, repo, collaborator string) (bool, error) {
status, err := c.getStatusCode("GET", fmt.Sprintf("/repos/%s/%s/collaborators/%s", url.PathEscape(owner), url.PathEscape(repo), collaborator), nil, nil)
collaborator
should bePathEscape
'd too.@6543 thank you for doing this! There's a few more things that probably need escaping too.
I'll look into it tomorow :)
@zeripath done
@ -66,2 +66,3 @@
func (c *Client) GetRepoBranch(owner, repo, branch string) (*Branch, error) {
b := new(Branch)
return b, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branches/%s", user, repo, branch), nil, nil, &b)
return b, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branches/%s", url.PathEscape(owner), url.PathEscape(repo), branch), nil, nil, &b)
Now this one is a bit difficult. We can't use pathescape however it's perfectly valid to have some weirdish characters in branch.
In Gitea proper we have a PathEscapeSegments:
Now this one is a bit difficult. We can't use pathescape however it's perfectly valid to have some weirdish characters in branch.
In Gitea proper we have a PathEscapeSegments:
@ -30,3 +31,3 @@
ref = strings.TrimPrefix(ref, "refs/")
r := new(Reference)
err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/refs/%s", user, repo, ref), nil, nil, &r)
err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/refs/%s", url.PathEscape(owner), url.PathEscape(repo), ref), nil, nil, &r)
Similarly here a ref can have non-urlsafe characters meaning we need PathEscapeSegments
Please resolve the conflicts.
Escape user and repo namesto Escape user, repo, refsEscape user, repo, refsto UrlEscape Function Arguments used in UrlPath@zeripath finished :)
CI is failing is unrelated ...
@ -115,12 +115,18 @@ type FileDeleteResponse struct {
// GetFile downloads a file of repository, ref can be branch/tag/commit.
// e.g.: ref -> master, tree -> macaron.go(no leading slash)
func (c *Client) GetFile(user, repo, ref, tree string) ([]byte, *Response, error) {
if err := escapeValidatePathSegments(&user, &repo, &ref, &tree); err != nil {
... escapeValidatePathSegments is not right for tree in that function
or ref
Those are allowed to have unescaped '/' in them but have to have everything else escaped...
@ -89,2 +98,3 @@
}
status := new(CombinedStatus)
resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/status", owner, repo, ref), jsonHeader, nil, status)
resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/status", owner, url.QueryEscape(ref), ref), jsonHeader, nil, status)
false params!
Looks like you missed
func (c *Client) issueBackwardsCompatibility(issue *Issue) {
@zeripath issueBackwardsCompatibility dont need that
should we add some notes to README, that the sdk now escape things by itselve?