MCPcopy Create free account
hub / github.com/PostHog/duckgres / SanitizeSearchPath

Function SanitizeSearchPath

server/startup_options.go:90–99  ·  view source on GitHub ↗

SanitizeSearchPath validates a client-supplied search_path so it can be safely embedded in `SET search_path = ' '`. Returns (trimmed, true) when the value is a plausible, injection-safe search_path; ("", false) otherwise (callers should then fall back to the default search_path).

(s string)

Source from the content-addressed store, hash-verified

88// when the value is a plausible, injection-safe search_path; ("", false)
89// otherwise (callers should then fall back to the default search_path).
90func SanitizeSearchPath(s string) (string, bool) {
91 s = strings.TrimSpace(s)
92 if s == "" || len(s) > 512 {
93 return "", false
94 }
95 if !safeSearchPathPattern.MatchString(s) {
96 return "", false
97 }
98 return s, true
99}

Callers 2

handleConnectionMethod · 0.92
TestSanitizeSearchPathFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestSanitizeSearchPathFunction · 0.68