Skip to content

Commit 3a00a69

Browse files
zeripathtechknowlogick
authored andcommitted
Prevent redirect to Host (#9678) (#9679)
1 parent a2b7cc1 commit 3a00a69

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

modules/context/context.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright 2014 The Gogs Authors. All rights reserved.
2+
// Copyright 2020 The Gitea Authors. All rights reserved.
23
// Use of this source code is governed by a MIT-style
34
// license that can be found in the LICENSE file.
45

@@ -122,7 +123,7 @@ func (ctx *Context) RedirectToFirst(location ...string) {
122123
}
123124

124125
u, err := url.Parse(loc)
125-
if err != nil || (u.Scheme != "" && !strings.HasPrefix(strings.ToLower(loc), strings.ToLower(setting.AppURL))) {
126+
if err != nil || ((u.Scheme != "" || u.Host != "") && !strings.HasPrefix(strings.ToLower(loc), strings.ToLower(setting.AppURL))) {
126127
continue
127128
}
128129

0 commit comments

Comments
 (0)