mirror of
https://github.com/go-gitea/gitea
synced 2025-07-16 07:18:37 +00:00
Refactor URL detection (#29960)
"Redirect" functions should only redirect if the target is for current Gitea site.
This commit is contained in:
@@ -44,14 +44,14 @@ func RedirectToUser(ctx *Base, userName string, redirectUserID int64) {
|
||||
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath), http.StatusTemporaryRedirect)
|
||||
}
|
||||
|
||||
// RedirectToFirst redirects to first not empty URL
|
||||
func (ctx *Context) RedirectToFirst(location ...string) {
|
||||
// RedirectToCurrentSite redirects to first not empty URL which belongs to current site
|
||||
func (ctx *Context) RedirectToCurrentSite(location ...string) {
|
||||
for _, loc := range location {
|
||||
if len(loc) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if httplib.IsRiskyRedirectURL(loc) {
|
||||
if !httplib.IsCurrentGiteaSiteURL(loc) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user