MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / quoteUser

Method quoteUser

internal/postgres/hba.go:84–98  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

82}
83
84func (hba *HostBasedAuthentication) quoteUser(name string) string {
85 // Since PostgreSQL 16, a quoted string beginning with slash U+002F is
86 // interpreted as a regular expression. Express these names as a Postgres
87 // regex that exactly matches the entire name.
88 if len(name) > 0 && name[0] == '/' {
89 name = "/^" +
90 hbaRegexSpecialCharacters.ReplaceAllStringFunc(name,
91 func(match string) string { return "[" + match + "]" }) +
92 "$"
93 }
94
95 // Quotes indicate the value is NOT a keyword (all), NOT a group (plus U+002B),
96 // and NOT to be expanded as a filename (at sign U+0040).
97 return hba.quote(name)
98}
99
100// AllDatabases makes hba match connections made to any database.
101func (hba *HostBasedAuthentication) AllDatabases() *HostBasedAuthentication {

Callers 1

UsersMethod · 0.95

Calls 1

quoteMethod · 0.95

Tested by

no test coverage detected