-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Don't Unescape redirect_to cookie value #6399
Don't Unescape redirect_to cookie value #6399
Conversation
redirect_to holds a value that we want to redirect back to after login. This value can be a path with intentonally escaped values and we should not unescape it. Fixes go-gitea#4475
Codecov Report
@@ Coverage Diff @@
## master #6399 +/- ##
=========================================
Coverage ? 38.85%
=========================================
Files ? 365
Lines ? 51389
Branches ? 0
=========================================
Hits ? 19965
Misses ? 28553
Partials ? 2871
Continue to review full report at Codecov.
|
@mrsdizzie thanks for PR 😃 please backport to release/v1.8 branch. |
redirect_to holds a value that we want to redirect back to after login. This value can be a path with intentonally escaped values and we should not unescape it. Fixes go-gitea#4475
redirect_to holds a value that we want to redirect back to after login. This value can be a path with intentionally escaped values and we should not unescape it.
I'd guess the original logic here is that all cookies are escaped and so you usually unescape them before using the values. However, getCookie already does unescaping so we are doing it twice.
To see this bad behavior: log out of try.gitea.io then visit this URL
https://try.gitea.io/mrsdizzie/parsing-errors/src/branch/master/%23testme
And click sign in from there. The path remains escaped until the final redirect after successful sign in at which point it redirects to the incorrect
https://try.gitea.io/mrsdizzie/parsing-errors/src/branch/master/#testme
which isn't rendered properly and just shows the main repo pageThat is because getCookie returns the unescaped
mrsdizzie/parsing-errors/src/branch/master/%23testme
and then the 2nd call to url.QueryUnescape turns that intomrsdizzie/parsing-errors/src/branch/master#testme
For reference, I bet things are this way because they predate the following change:
go-macaron/macaron@b7c39df#diff-05a3aa0ab9e5687ff167e0ef3ae4c5a6R300
Fixes #4475