| 82 | } |
| 83 | |
| 84 | func (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. |
| 101 | func (hba *HostBasedAuthentication) AllDatabases() *HostBasedAuthentication { |