summaryrefslogtreecommitdiffstats
path: root/modules/context/context_response.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-06-16 14:32:43 +0800
committerGitHub <noreply@github.com>2023-06-16 06:32:43 +0000
commitb71cb7acdc8840c9fc16b496c90a048051d15823 (patch)
treefae5454a2c9f1a7d510255260b562519681841c0 /modules/context/context_response.go
parenta305c37e62eca42aaad16b4521520bad6bca58d2 (diff)
downloadgitea-b71cb7acdc8840c9fc16b496c90a048051d15823.tar.gz
gitea-b71cb7acdc8840c9fc16b496c90a048051d15823.zip
Use fetch to send requests to create issues/comments (#25258)
Follow #23290 Network error won't make content lost. And this is a much better approach than "loading-button". The UI is not perfect and there are still some TODOs, they can be done in following PRs, not a must in this PR's scope. <details> ![image](https://github.com/go-gitea/gitea/assets/2114189/c94ba958-aa46-4747-8ddf-6584deeed25c) </details>
Diffstat (limited to 'modules/context/context_response.go')
-rw-r--r--modules/context/context_response.go10
1 files changed, 2 insertions, 8 deletions
diff --git a/modules/context/context_response.go b/modules/context/context_response.go
index 1f215eb8ad..88e375986c 100644
--- a/modules/context/context_response.go
+++ b/modules/context/context_response.go
@@ -16,6 +16,7 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/base"
+ "code.gitea.io/gitea/modules/httplib"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/templates"
@@ -49,14 +50,7 @@ func (ctx *Context) RedirectToFirst(location ...string) {
continue
}
- // Unfortunately browsers consider a redirect Location with preceding "//", "\\" and "/\" as meaning redirect to "http(s)://REST_OF_PATH"
- // Therefore we should ignore these redirect locations to prevent open redirects
- if len(loc) > 1 && (loc[0] == '/' || loc[0] == '\\') && (loc[1] == '/' || loc[1] == '\\') {
- continue
- }
-
- u, err := url.Parse(loc)
- if err != nil || ((u.Scheme != "" || u.Host != "") && !strings.HasPrefix(strings.ToLower(loc), strings.ToLower(setting.AppURL))) {
+ if httplib.IsRiskyRedirectURL(loc) {
continue
}