-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Escape branch string before inserting it in URL #2948
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2948 +/- ##
=======================================
Coverage 98.17% 98.17%
=======================================
Files 145 145
Lines 12735 12735
=======================================
Hits 12502 12502
Misses 158 158
Partials 75 75
|
Honestly, I'm quite surprised that this issue has never come up before... as this repo is how many years old? 10?!? However, I think you are right. I'm wondering if each of the modified endpoints needs a comment in the documentation stating something like:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add unit tests that demonstrate this new super power?
c44f623
to
2423e20
Compare
@gmlewis PR updated with additional comments and unit tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @k0ral !
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
I have a bit of concern about this being a subtle breaking change that could take a long time to discover after upgrading. I'm looking at ways to mitigate that. I'll be back to review later today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still a little hesitant about the breaking change, but after a some pondering I can't come up with anything better that doesn't add unnecessary complexity.
Thank you, @WillAbides ! |
When a branch name with special characters like
%
is passed to theRepositoryService.GetBranch()
method as is, an error is currently returned:Passing an escaped branch name to
RepositoriesService.GetBranch()
works fine.Here's a minimal reproducer
This sounds like a bug to me, as I believe users of that method shouldn't be expected to escape the branch name before calling it, as this is a private implementation quirk that they shouldn't be aware of. This PR patches all branch-related methods to automatically escape the branch name in the endpoint URL.
There's actually a precedent for
ref
parameter, and I suspect that other variables are prone to the same issue. I am conservatively patching only the branch variable, as this is the only one I have tested thoroughly. Note that, contrary toref
use case, my tests suggest that it's okay to escape/
characters for branch names.RepositoryService.GetBranch()
method (and other branch-related methods), this change will be breaking.