summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-05-08 21:34:43 +0800
committerGitHub <noreply@github.com>2024-05-08 13:34:43 +0000
commitd4c2db39bf239d071c6ac96815efa8fd8b03ad94 (patch)
tree158b7a40af6d1637d57cdde078d94bf1d7c95404 /services
parentd410e2acce22e5b3518a9bf64a9152b32a91fe18 (diff)
downloadgitea-d4c2db39bf239d071c6ac96815efa8fd8b03ad94.tar.gz
gitea-d4c2db39bf239d071c6ac96815efa8fd8b03ad94.zip
Refactor AppURL usage (#30885) (#30891)
Backport #30885 Fix #30883 Fix #29591 Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Diffstat (limited to 'services')
-rw-r--r--services/context/base.go2
-rw-r--r--services/context/context_response.go2
2 files changed, 2 insertions, 2 deletions
diff --git a/services/context/base.go b/services/context/base.go
index 05b8ab1b9b..29e62ae389 100644
--- a/services/context/base.go
+++ b/services/context/base.go
@@ -254,7 +254,7 @@ func (b *Base) Redirect(location string, status ...int) {
code = status[0]
}
- if strings.HasPrefix(location, "http://") || strings.HasPrefix(location, "https://") || strings.HasPrefix(location, "//") {
+ if !httplib.IsRelativeURL(location) {
// Some browsers (Safari) have buggy behavior for Cookie + Cache + External Redirection, eg: /my-path => https://other/path
// 1. the first request to "/my-path" contains cookie
// 2. some time later, the request to "/my-path" doesn't contain cookie (caused by Prevent web tracking)
diff --git a/services/context/context_response.go b/services/context/context_response.go
index 87c34c35ed..c43a649b49 100644
--- a/services/context/context_response.go
+++ b/services/context/context_response.go
@@ -52,7 +52,7 @@ func (ctx *Context) RedirectToCurrentSite(location ...string) {
continue
}
- if !httplib.IsCurrentGiteaSiteURL(loc) {
+ if !httplib.IsCurrentGiteaSiteURL(ctx, loc) {
continue
}