mirror of
https://github.com/gin-gonic/gin.git
synced 2026-09-04 14:49:27 +08:00
Merge b6b4916492d518d5e75914a8ee9a7ca6837785c2 into dcaa4296d111981ffb31ac3eba90bb63e1eb5ab9
This commit is contained in:
commit
fcc9c19971
7
path.go
7
path.go
@ -25,6 +25,13 @@ func cleanPath(p string) string {
|
|||||||
if p == "" {
|
if p == "" {
|
||||||
return "/"
|
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.
|
// Reasonably sized buffer on stack to avoid allocations in the common case.
|
||||||
// If a larger buffer is required, it gets allocated dynamically.
|
// If a larger buffer is required, it gets allocated dynamically.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user