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: |
gmlewis
left a comment
There was a problem hiding this comment.
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. |
|
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. |
WillAbides
left a comment
There was a problem hiding this comment.
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
refparameter, 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 torefuse 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.