-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Remove padding characters from random strings #15536
Conversation
* base64.RawURLEncoding added in go 1.15, can remove padding '=' characters from base64 strings
Do we need to make changes to tolerate the raw url encoding when it comes back to us? |
Current project 's minimal support Golang version defined in |
It is the correct encoding and I'd say this is a client-side error generally. Still probably fine to trim off the base64 padding as it is optional. A test would be nice. |
On second thought, I think this function should not generate non-alphanumeric characters in first place as they all can cause issues in URLs. The RFC4648 base64 variant that golang uses can produce I think we should just generate alphanumeric only, e.g. |
So how about to use |
|
Alternative, more extensive PR: #15741 |
- Replace 3 functions that do the same with 1 shared one - Use crypto/rand over math/rand for a stronger RNG - Output only alphanumerical for URL compatibilty Fixes: go-gitea#15536
* Use single shared random string generation function - Replace 3 functions that do the same with 1 shared one - Use crypto/rand over math/rand for a stronger RNG - Output only alphanumerical for URL compatibilty Fixes: #15536 * use const string method * Update modules/avatar/avatar.go Co-authored-by: a1012112796 <1012112796@qq.com> Co-authored-by: a1012112796 <1012112796@qq.com>
* Use single shared random string generation function - Replace 3 functions that do the same with 1 shared one - Use crypto/rand over math/rand for a stronger RNG - Output only alphanumerical for URL compatibilty Fixes: go-gitea#15536 * use const string method * Update modules/avatar/avatar.go Co-authored-by: a1012112796 <1012112796@qq.com> Co-authored-by: a1012112796 <1012112796@qq.com>
can remove padding '=' characters from base64 strings
When I use gitea as a OIDC provider, I find the
code
generated by gitea is a base64 string contains=
Then the redirect query become
The
=
in code encoded to%3D
and may cause some error. This commit removes the padding characters