Merge b6b4916492d518d5e75914a8ee9a7ca6837785c2 into 0f09c3a9b4626d9fe9979cf4d0521d6ae32ab646

This commit is contained in:
Mohamad Nimer 2026-10-13 02:27:52 -07:00 committed by GitHub
commit 42d2360463
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -25,6 +25,13 @@ func cleanPath(p string) string {
if p == "" {
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.
// If a larger buffer is required, it gets allocated dynamically.