Escape commit ref with percent encoding#1099
Conversation
|
I'm curious if there are other APIs in our repo where we have made the same mistake? I'm betting that anywhere we pass a While you are here, @bgpat, do you want to take a look? |
|
I found 9 same mistakes. I will fix it. $ grep -n Sprintf *.go | grep ', ref\W'
checks.go:258: u := fmt.Sprintf("repos/%v/%v/commits/%v/check-runs", owner, repo, ref)
checks.go:324: u := fmt.Sprintf("repos/%v/%v/commits/%v/check-suites", owner, repo, ref)
git_refs.go:60: u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, ref)
git_refs.go:91: u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, ref)
git_refs.go:211: u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, ref)
repos_commits.go:192: u := fmt.Sprintf("repos/%v/%v/commits/%v", owner, repo, ref)
repos_statuses.go:47: u := fmt.Sprintf("repos/%v/%v/commits/%v/statuses", owner, repo, ref)
repos_statuses.go:72: u := fmt.Sprintf("repos/%v/%v/statuses/%v", owner, repo, ref)
repos_statuses.go:111: u := fmt.Sprintf("repos/%v/%v/commits/%v/status", owner, repo, ref) |
|
@gmlewis I escaped all |
|
OK, this is true awesomeness... thank you so much, @bgpat! Awaiting input from @gauntface as a sanity check to make sure my review makes sense... then we will get this in. |
gauntface
left a comment
There was a problem hiding this comment.
This looks great to me. We should look at adding some tests to make sure we don't regress on this in the future, but that can be done separately.
Thank you for fixing this :)
|
Excellent point, @gauntface! |
|
This is a bug fix. Bumping package version number to capture it. |
as given in the original google#1099
If
Repositories.GetCommitSHA1was called with the branch name which includes non-alphabet character, it occurs an error. It looks to require escaping with percent encoding.Below is sample code:
before:
parse repos/bgpat/test/commits/cpu100%: invalid URL escape "%"after:
46736bd30fe65160f7d21e49d8f23e4687abc41b