MCPcopy
hub / github.com/pocketbase/pocketbase / safeRedirectPath

Function safeRedirectPath

apis/base.go:175–180  ·  view source on GitHub ↗

safeRedirectPath normalizes the path string by replacing all beginning slashes (`\\`, `//`, `\/`) with a single forward slash to prevent open redirect attacks

(path string)

Source from the content-addressed store, hash-verified

173// safeRedirectPath normalizes the path string by replacing all beginning slashes
174// (`\\`, `//`, `\/`) with a single forward slash to prevent open redirect attacks
175func safeRedirectPath(path string) string {
176 if len(path) > 1 && (path[0] == '\\' || path[0] == '/') && (path[1] == '\\' || path[1] == '/') {
177 path = "/" + strings.TrimLeft(path, `/\`)
178 }
179 return path
180}

Callers 1

StaticFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…