UrlEscape Function Arguments used in UrlPath #273

Merged
zeripath merged 18 commits from 6543/go-sdk:EscapeUserRepoNames into master 2021-03-21 20:20:33 +00:00
Owner

close #271

  • add check if user/repo-name is empty
  • use net/url for links to encode
close #271 * [x] add check if user/repo-name is empty * [x] use net/url for links to encode
6543 added this to the v0.12.0 milestone 2020-02-08 11:34:47 +00:00
6543 added the
kind/enhancement
label 2020-02-08 11:34:47 +00:00
Author
Owner

extracted fix to #276

extracted fix to #276
zeripath reviewed 2020-02-09 18:48:08 +00:00
Dismissed
@ -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)
Owner

If id is passed in to the library as an option it also needs to be PathEscape'd

If `id` is passed in to the library as an option it also needs to be `PathEscape`'d
6543 marked this conversation as resolved
zeripath reviewed 2020-02-09 18:48:09 +00:00
Dismissed
Owner

If id is passed in to the library as an option it also needs to be PathEscape'd

If `id` is passed in to the library as an option it also needs to be `PathEscape`'d
6543 marked this conversation as resolved
zeripath reviewed 2020-02-09 18:52:08 +00:00
Dismissed
@ -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)
Owner

user here probably needs PathEscape too.

`user` here probably needs `PathEscape` too.
6543 marked this conversation as resolved
zeripath reviewed 2020-02-09 18:52:37 +00:00
Dismissed
@ -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, &times)
return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times/%s", url.PathEscape(owner), url.PathEscape(repo), user), nil, nil, &times)
Owner

user here probably needs PathEscape

`user` here probably needs `PathEscape`
6543 marked this conversation as resolved
zeripath reviewed 2020-02-09 18:52:39 +00:00
Dismissed
Owner

user here probably needs PathEscape

`user` here probably needs `PathEscape`
6543 marked this conversation as resolved
zeripath reviewed 2020-02-09 18:53:41 +00:00
Dismissed
@ -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)
Owner

sha should probably be PathEscaped too.

`sha` should probably be `PathEscape`d too.
6543 marked this conversation as resolved
zeripath reviewed 2020-02-09 18:54:28 +00:00
Dismissed
gitea/hook.go Outdated
@ -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)
Owner

If id is passed in to the library as an option it also needs to be PathEscape'd

If `id` is passed in to the library as an option it also needs to be `PathEscape`'d
Author
Owner

id is an integer

id is an integer
6543 marked this conversation as resolved
zeripath reviewed 2020-02-09 18:56:09 +00:00
Dismissed
@ -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)
Owner

collaborator should be PathEscape'd too.

`collaborator` should be `PathEscape`'d too.
6543 marked this conversation as resolved
Owner

@6543 thank you for doing this! There's a few more things that probably need escaping too.

@6543 thank you for doing this! There's a few more things that probably need escaping too.
Author
Owner

I'll look into it tomorow :)

I'll look into it tomorow :)
Author
Owner

@zeripath done

@zeripath done
zeripath reviewed 2020-02-14 09:16:35 +00:00
Dismissed
@ -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)
Owner

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:

// PathEscapeSegments escapes segments of a path while not escaping forward slash
func PathEscapeSegments(path string) string {
	slice := strings.Split(path, "/")
	for index := range slice {
		slice[index] = url.PathEscape(slice[index])
	}
	escapedPath := strings.Join(slice, "/")
	return escapedPath
}
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: ```go // PathEscapeSegments escapes segments of a path while not escaping forward slash func PathEscapeSegments(path string) string { slice := strings.Split(path, "/") for index := range slice { slice[index] = url.PathEscape(slice[index]) } escapedPath := strings.Join(slice, "/") return escapedPath } ```
6543 marked this conversation as resolved
zeripath reviewed 2020-02-14 09:16:37 +00:00
Dismissed
Owner

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:

// PathEscapeSegments escapes segments of a path while not escaping forward slash
func PathEscapeSegments(path string) string {
	slice := strings.Split(path, "/")
	for index := range slice {
		slice[index] = url.PathEscape(slice[index])
	}
	escapedPath := strings.Join(slice, "/")
	return escapedPath
}
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: ```go // PathEscapeSegments escapes segments of a path while not escaping forward slash func PathEscapeSegments(path string) string { slice := strings.Split(path, "/") for index := range slice { slice[index] = url.PathEscape(slice[index]) } escapedPath := strings.Join(slice, "/") return escapedPath } ```
6543 marked this conversation as resolved
zeripath reviewed 2020-02-14 09:18:04 +00:00
Dismissed
@ -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)
Owner

Similarly here a ref can have non-urlsafe characters meaning we need PathEscapeSegments

Similarly here a ref can have non-urlsafe characters meaning we need PathEscapeSegments
6543 marked this conversation as resolved
6543 added the
status/wip
label 2020-04-04 02:31:30 +00:00
6543 modified the milestone from v0.12.0 to v0.12.1 2020-05-18 18:46:47 +00:00
Owner

Please resolve the conflicts.

Please resolve the conflicts.
6543 added 16 commits 2020-05-21 11:59:47 +00:00
All checks were successful
continuous-integration/drone/push Build is passing
9f10a2b902
Add Create/Get/Delete for oauth2 apps (#305)
Add Create/Get/Delete for oauth2 apps

  Add Create, List, and Delete for Oauth2 applications.
  Tests were added as well.

Co-authored-by: Dan Molik <dan@danmolik.com>
Reviewed-on: #305
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: 6543 <6543@noreply.gitea.io>
All checks were successful
continuous-integration/drone/push Build is passing
2f920dbb01
Add missing JSON header to `Client.AddCollaborator` (#306)
Add missing JSON header to `Client.AddCollaborator`

Reviewed-on: #306
Reviewed-by: 6543 <6543@noreply.gitea.io>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
All checks were successful
continuous-integration/drone/push Build is passing
50efd911c8
Tune CheckNotifications for api change (#308)
notification Check now always return json

make fmt relicts

CheckNotifications: one api call is enouth

add getResponseWithStatus to handle Response customized based on Status

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #308
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Andrew Thornton <art27@cantab.net>
All checks were successful
continuous-integration/drone/push Build is passing
0cf676d9f9
Add Get/Update for oauth2 apps (#311)
Update Documentation for Oauth2 Application delete

also fix variable names to be similar to existing functions

Signed-off-by: Dan Molik <dan@danmolik.com>

Add Get/Update for oauth2 apps

  Add a get by id function for oauth applications, and add an update
  function, also ensuring the oauth2 update regenerates the client
  secret.

Signed-off-by: Dan Molik <dan@danmolik.com>

Co-authored-by: Dan Molik <dan@danmolik.com>
Reviewed-on: #311
Reviewed-by: 6543 <6543@noreply.gitea.io>
Reviewed-by: Andrew Thornton <art27@cantab.net>
79665cae15 Fix MergePullRequest & extend Tests (#278)
rm MergePullRequestResponse

Fix MergePullRequest

Extend Tests

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #278
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
All checks were successful
continuous-integration/drone/push Build is passing
7dfa25bb30
Add Issue Subscription Check & Fix DeleteIssueSubscription (#318)
add subscription tests

make createTestIssue reusable

Add CheckIssueSubscription

fix

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #318
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: lafriks <lafriks@noreply.gitea.io>
All checks were successful
continuous-integration/drone/push Build is passing
50560273b9
Add Branch Deletion (#317)
add TEST for branches

dont return empty branch on error

add DeleteBranch func

Co-authored-by: lafriks <lafriks@noreply.gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #317
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: lafriks <lafriks@noreply.gitea.io>
All checks were successful
continuous-integration/drone/push Build is passing
36d2964230
API split for: to get single commit via SHA and Ref (#319)
Split API

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #319
Reviewed-by: lafriks <lafriks@noreply.gitea.io>
Reviewed-by: Andrew Thornton <art27@cantab.net>
All checks were successful
continuous-integration/drone/push Build is passing
7ae928fbc2
[Frontport] Changelog for v0.11.3 & newline fix (#321)
fix newline in readme

Changelog v0.11.3 (#320)

Changelog v0.11.3

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #320
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #321
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
All checks were successful
continuous-integration/drone/push Build is passing
fb7355a186
IssueUn-/Subscription take care of new 200 status (#325)
IssueUn-/Subscription handle 200 status

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #325
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: lafriks <lafriks@noreply.gitea.io>
All checks were successful
continuous-integration/drone/push Build is passing
2883376503
Revert "API split for: to get single commit via SHA and Ref (#319)" (#324)
Merge branch 'master' into revert-commit-api-split

Revert "API split for: to get single commit via SHA and Ref (#319)"

This reverts commit 36d2964230.

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #324
Reviewed-by: lafriks <lafriks@noreply.gitea.io>
Reviewed-by: Andrew Thornton <art27@cantab.net>
All checks were successful
continuous-integration/drone/push Build is passing
93087537ff
Corect test Title: TestIssueSubscription (#326)
Corect test Title: TestIssueSubscription

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #326
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
All checks were successful
continuous-integration/drone/push Build is passing
70863f4458
Support 2FA for basic auth & refactor Token functions (#335)
BREAKING: Token functions: remove username&passwd param - use default client auth way

refactor

add otp Field

refacotr ...

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #335
Reviewed-by: John Olheiser <john.olheiser@gmail.com>
Reviewed-by: Andrew Thornton <art27@cantab.net>
All checks were successful
continuous-integration/drone/push Build is passing
f224b4e50c
ListIssues: add milestones filter (#327)
use string.Join

Code Format

add test case

add Milestones to ListIssueOption

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #327
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
All checks were successful
continuous-integration/drone/push Build is passing
bb6248f50d
Add paggination to ListNotification functions (#339)
Merge branch 'master' into update-notifications

Merge branch 'master' into update-notifications

rm nonesence - dont know why i put it there

add paggination to ListNotification functions

refactor

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #339
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Andrew Thornton <art27@cantab.net>
All checks were successful
continuous-integration/drone/push Build is passing
2cc36f912f
Check if gitea is able to squash-merge via API (#336)
Check if gitea is able to squash-merge via API

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #336
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: CirnoT <cirnot@noreply.gitea.io>
6543 added 5 commits 2020-06-04 11:53:13 +00:00
All checks were successful
continuous-integration/drone/push Build is passing
bb9144e8d6
Add Migration Guide for v0.12.0 (#343)
Add Migration Guide: v0.11 to v0.12

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #343
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
All checks were successful
continuous-integration/drone/push Build is passing
2e81813c45
Add BranchProtection functions (#341)
Merge branch 'master' into branch-protection

Merge branch 'master' into branch-protection

Merge branch 'master' into branch-protection

Merge branch 'master' into branch-protection

Merge branch 'master' into branch-protection

fix + add TESTS

first draft

Add structs and placeholder

Update Branch struct

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #341
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
All checks were successful
continuous-integration/drone/push Build is passing
057518ef80
Add PullReview functions (#338)
add TESTS

better name

First Version

Add Structs & function placeholders

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #338
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
All checks were successful
continuous-integration/drone/push Build is passing
567d2f8bbd
Changelog v0.12.0 (#344)
Add Changelog v0.12.0

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #344
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
All checks were successful
continuous-integration/drone/push Build is passing
e7c56d8f50
fix ineffassign in Tests & set Version v0.13.0 (#345)
increment version

fix ineffassign

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: #345
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Andrew Thornton <art27@cantab.net>
6543 modified the milestone from v0.12.1 to v0.13.0 2020-07-08 17:35:34 +00:00
6543 changed title from Escape user and repo names to Escape user, repo, refs 2020-09-12 15:22:02 +00:00
6543 modified the milestone from v0.13.0 to v0.14.0 2020-09-12 15:22:13 +00:00
6543 added 1 commit 2020-11-10 19:15:37 +00:00
Some checks failed
continuous-integration/drone/pr Build is failing
c0dd753977
... adoption ...
6543 added 1 commit 2020-11-10 19:51:29 +00:00
Some checks failed
continuous-integration/drone/pr Build is failing
06fbde5422
... Done
6543 changed title from Escape user, repo, refs to UrlEscape Function Arguments used in UrlPath 2020-11-10 19:57:31 +00:00
6543 removed the
status/wip
label 2020-11-10 20:01:10 +00:00
Author
Owner

@zeripath finished :)

CI is failing is unrelated ...

@zeripath finished :) CI is failing is unrelated ...
6543 added the
status/needs-reviews
label 2020-11-10 20:16:47 +00:00
6543 added 1 commit 2020-11-10 20:24:07 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing
fe238ca9d6
Update TestData
6543 added 1 commit 2020-11-12 21:35:40 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing
2bfe1cd507
Merge branch 'master' into EscapeUserRepoNames
6543 added 1 commit 2020-11-14 13:07:53 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing
713aa7b7c3
Merge branch 'master' into EscapeUserRepoNames
6543 added 1 commit 2020-11-29 15:10:08 +00:00
Some checks failed
continuous-integration/drone/pr Build is failing
6c8ca797a7
Merge branch 'master' into EscapeUserRepoNames
6543 reviewed 2021-02-16 18:35:47 +00:00
Dismissed
@ -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 {
Author
Owner

... 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...

... 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...
6543 marked this conversation as resolved
6543 added 2 commits 2021-02-19 23:53:28 +00:00
Some checks failed
continuous-integration/drone/pr Build is failing
2859653284
... wip ...
6543 added 1 commit 2021-03-08 21:44:43 +00:00
Some checks failed
continuous-integration/drone/pr Build is failing
0a1d265e17
Merge branch 'master' into EscapeUserRepoNames
6543 reviewed 2021-03-08 21:56:19 +00:00
Dismissed
gitea/status.go Outdated
@ -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)
Author
Owner

false params!

false params!
6543 marked this conversation as resolved
6543 reviewed 2021-03-08 21:57:01 +00:00
Dismissed
6543 added 1 commit 2021-03-08 22:04:33 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing
0a9af0f1b0
fix issues
6543 added 1 commit 2021-03-08 22:28:43 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing
00e007e87f
finish
Owner

Looks like you missed func (c *Client) issueBackwardsCompatibility(issue *Issue) {

Looks like you missed `func (c *Client) issueBackwardsCompatibility(issue *Issue) {`
Author
Owner

@zeripath issueBackwardsCompatibility dont need that

@zeripath **issueBackwardsCompatibility** dont need that
Author
Owner

should we add some notes to README, that the sdk now escape things by itselve?

should we add some notes to README, that the sdk now escape things by itselve?
zeripath approved these changes 2021-03-12 17:57:46 +00:00
Dismissed
6543 added the
kind/breaking
label 2021-03-19 21:22:52 +00:00
6543 added 1 commit 2021-03-19 21:28:21 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing
7998124ed3
docs
6543 modified the milestone from v0.14.0 to v0.14.1 2021-03-21 11:12:32 +00:00
6543 modified the milestone from v0.14.1 to v0.15.0 2021-03-21 11:13:55 +00:00
techknowlogick approved these changes 2021-03-21 19:27:45 +00:00
Dismissed
zeripath merged commit 6b6fdd91ce into master 2021-03-21 20:20:33 +00:00
6543 deleted branch EscapeUserRepoNames 2021-03-21 20:22:01 +00:00
6543 removed the
status/needs-reviews
label 2021-03-21 20:22:12 +00:00
6543 modified the milestone from v0.15.0 to v0.14.0 2021-03-21 20:22:18 +00:00
Sign in to join this conversation.
No description provided.