fixed open redirect

This commit is contained in:
cyal1 2024-03-28 23:05:09 +08:00 committed by GitHub
parent 7a865dcf1d
commit 6c8ec4deda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

1
gin.go
View File

@ -699,6 +699,7 @@ func redirectTrailingSlash(c *Context) {
p = prefix + "/" + req.URL.Path
}
req.URL.Path = p + "/"
p = regRemoveRepeatedChar.ReplaceAllString(p, "/")
if length := len(p); length > 1 && p[length-1] == '/' {
req.URL.Path = p[:length-1]
}