Skip to content

Commit

Permalink
remove comma to avoid to split the strings and confuse the search
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Labarussias <issif+github@gadz.org>
  • Loading branch information
Issif authored and poiana committed Apr 30, 2024
1 parent fba1b77 commit 01947af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/database/redis/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func SetKey(client *redisearch.Client, event *models.Event) error {
doc := redisearch.NewDocument(fmt.Sprintf("event:%v", event.UUID), 1.0).
Set("rule", event.Rule).
Set("priority", event.Priority).
Set("output", utils.Escape(event.Output)).
Set("output", strings.ReplaceAll(utils.Escape(event.Output), ",", "")).
Set("source", event.Source).
Set("timestamp", event.Time.UnixNano()/1e3).
Set("tags", utils.Escape(strings.Join(event.Tags, ","))).
Expand Down
4 changes: 2 additions & 2 deletions internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func GetPriortiyInt(prio string) int {

func Escape(s string) string {
s = strings.ReplaceAll(s, ".", `\.`)
s = strings.ReplaceAll(s, ",", "\\,")
// s = strings.ReplaceAll(s, ",", "\\,")
s = strings.ReplaceAll(s, "<", "\\<")
s = strings.ReplaceAll(s, ">", "\\>")
s = strings.ReplaceAll(s, "{", "\\{")
Expand Down Expand Up @@ -196,8 +196,8 @@ func Escape(s string) string {
}

func UnEscape(s string) string {
s = strings.ReplaceAll(s, "\\,", ",")
s = strings.ReplaceAll(s, `\.`, ".")
// s = strings.ReplaceAll(s, "\\,", ",")
s = strings.ReplaceAll(s, "\\<", "<")
s = strings.ReplaceAll(s, "\\>", ">")
s = strings.ReplaceAll(s, "\\{", "{")
Expand Down

0 comments on commit 01947af

Please sign in to comment.