Invalid redirection on branches with # in their name
#85319
Unanswered
k0ral
asked this question in
Apps, API and Webhooks
Replies: 2 comments
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
Hi @k0ral, Thanks so much for reaching out in our community. It sounds like this may be expected behavior. When using a CLI, you might have situations where a branch or tag name contains special characters that have a special meaning for your shell environment. To use these characters safely in a Git command, they must be quoted or escaped, otherwise the command may have unintended effects: Dealing with special characters in branch and tag names. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Bug
Body
I've created a repository to showcase the issue, where:
branch-namebranch-nameintobranch-name#42Scenario
Send HTTP GET to https://api.github.com/repos/k0ral/test-branch-redirection/branches/branch-name and follow redirections until you get a valid HTTP 200 response.
Current behavior
Locationheader set to https://api.github.com/repos/k0ral/test-branch-redirection/branches/branch-name#42 (notice that the#character isn't escaped)Locationheader set to https://api.github.com/repos/k0ral/test-branch-redirection/branches/branch-name#42 (i.e. itself)Desired behavior
Locationheader set to https://api.github.com/repos/k0ral/test-branch-redirection/branches/branch-name%2342 (#is escaped)Analysis
The unescaped
#character is interpreted as an URL anchor, ignored by the API, so https://api.github.com/repos/k0ral/test-branch-redirection/branches/branch-name#42 is equivalent to https://api.github.com/repos/k0ral/test-branch-redirection/branches/branch-name , hence the infinite redirection.Beta Was this translation helpful? Give feedback.
All reactions