mirror of
https://github.com/gogs/gogs.git
synced 2026-05-07 06:36:04 +02:00
Replace tool.IsMaliciousPath with pathutil.Clean and move IsSameSite to urlutil (#8106)
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
"gogs.io/gogs/internal/email"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
"gogs.io/gogs/internal/urlutil"
|
||||
"gogs.io/gogs/internal/userutil"
|
||||
)
|
||||
|
||||
@@ -92,7 +93,7 @@ func Login(c *context.Context) {
|
||||
}
|
||||
|
||||
if isSucceed {
|
||||
if tool.IsSameSiteURLPath(redirectTo) {
|
||||
if urlutil.IsSameSite(redirectTo) {
|
||||
c.Redirect(redirectTo)
|
||||
} else {
|
||||
c.RedirectSubpath("/")
|
||||
@@ -138,7 +139,7 @@ func afterLogin(c *context.Context, u *database.User, remember bool) {
|
||||
|
||||
redirectTo, _ := url.QueryUnescape(c.GetCookie("redirect_to"))
|
||||
c.SetCookie("redirect_to", "", -1, conf.Server.Subpath)
|
||||
if tool.IsSameSiteURLPath(redirectTo) {
|
||||
if urlutil.IsSameSite(redirectTo) {
|
||||
c.Redirect(redirectTo)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/database"
|
||||
"gogs.io/gogs/internal/route/repo"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
"gogs.io/gogs/internal/urlutil"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -122,7 +122,7 @@ func Action(c *context.Context, puser *context.ParamsUser) {
|
||||
}
|
||||
|
||||
redirectTo := c.Query("redirect_to")
|
||||
if !tool.IsSameSiteURLPath(redirectTo) {
|
||||
if !urlutil.IsSameSite(redirectTo) {
|
||||
redirectTo = puser.HomeURLPath()
|
||||
}
|
||||
c.Redirect(redirectTo)
|
||||
|
||||
Reference in New Issue
Block a user