Rename deEscape to unescape

This commit is contained in:
David Dworken 2023-02-13 21:36:54 -08:00
parent f79ab37bcf
commit b6eb4da4f3
No known key found for this signature in database

View File

@ -1150,14 +1150,14 @@ func Search(ctx *context.Context, db *gorm.DB, query string, limit int) ([]*data
}
func parseNonAtomizedToken(token string) (string, interface{}, interface{}, interface{}, error) {
wildcardedToken := "%" + deEscape(token) + "%"
wildcardedToken := "%" + unescape(token) + "%"
return "(command LIKE ? OR hostname LIKE ? OR current_working_directory LIKE ?)", wildcardedToken, wildcardedToken, wildcardedToken, nil
}
func parseAtomizedToken(ctx *context.Context, token string) (string, interface{}, interface{}, error) {
splitToken := splitEscaped(token, ':', 2)
field := deEscape(splitToken[0])
val := deEscape(splitToken[1])
field := unescape(splitToken[0])
val := unescape(splitToken[1])
switch field {
case "user":
return "(local_username = ?)", val, nil, nil
@ -1273,7 +1273,7 @@ func containsUnescaped(query string, token string) bool {
return false
}
func deEscape(query string) string {
func unescape(query string) string {
runeQuery := []rune(query)
var newQuery []rune
for i := 0; i < len(runeQuery); i++ {