fix: resolve pr comments

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Mohamad Nimer 2026-07-03 02:54:21 +03:00
parent bb6335b24a
commit d7de89f01f

View File

@ -25,9 +25,12 @@ func cleanPath(p string) string {
if p == "" { if p == "" {
return "/" return "/"
} }
// Prevent scheme-relative or backslash-based absolute redirects. // Prevent scheme-relative ("//...") or backslash-based absolute ("/\\...") paths.
if len(p) > 1 && p[0] == '/' && (p[1] == '/' || p[1] == '\\') { for len(p) > 1 && p[0] == '/' && p[1] == '/' {
return "/" 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. // Reasonably sized buffer on stack to avoid allocations in the common case.