mirror of
https://github.com/gin-gonic/gin.git
synced 2026-09-12 04:46:06 +08:00
fix: resolve pr comments
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
2e1ca6211b
commit
b9169f85ef
9
path.go
9
path.go
@ -25,9 +25,12 @@ func cleanPath(p string) string {
|
||||
if p == "" {
|
||||
return "/"
|
||||
}
|
||||
// Prevent scheme-relative or backslash-based absolute redirects.
|
||||
if len(p) > 1 && p[0] == '/' && (p[1] == '/' || p[1] == '\\') {
|
||||
return "/"
|
||||
// Prevent scheme-relative ("//...") or backslash-based absolute ("/\\...") paths.
|
||||
for len(p) > 1 && p[0] == '/' && p[1] == '/' {
|
||||
p = p[1:]
|
||||
}
|
||||
if len(p) > 1 && p[0] == '/' && p[1] == '\\' {
|
||||
p = "/" + p[2:]
|
||||
}
|
||||
|
||||
// Reasonably sized buffer on stack to avoid allocations in the common case.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user