mirror of
https://github.com/go-gitea/gitea.git
synced 2026-02-22 04:35:44 +01:00
Merge 2c742717c8616703a22041f6f9164ec10cadaad9 into bbea5e6c2d75a4a710d7838b7bec7e851e046d3c
This commit is contained in:
commit
5f4c92cd42
@ -24,6 +24,10 @@ func urlIsRelative(s string, u *url.URL) bool {
|
||||
if len(s) > 1 && (s[0] == '/' || s[0] == '\\') && (s[1] == '/' || s[1] == '\\') {
|
||||
return false
|
||||
}
|
||||
// Backslashes (including encoded) can be normalized by browsers into slashes and allow open redirects.
|
||||
if strings.Contains(s, "\\") || strings.Contains(strings.ToLower(s), "%5c") {
|
||||
return false
|
||||
}
|
||||
return u != nil && u.Scheme == "" && u.Host == ""
|
||||
}
|
||||
|
||||
|
||||
@ -32,6 +32,8 @@ func TestIsRelativeURL(t *testing.T) {
|
||||
"\\\\",
|
||||
"/\\",
|
||||
"\\/",
|
||||
"/a/../\\example.com",
|
||||
"/a/../%5cexample.com",
|
||||
"mailto:a@b.com",
|
||||
"https://test.com",
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user