From f8b44528801a7a6b92179bea66f3fbdf4d0c9b03 Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Sun, 25 Aug 2024 23:15:47 +0100 Subject: [PATCH] [FIX] Incorrect usage of regexp library --- calendar.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/calendar.go b/calendar.go index 3d4dfa1..0a9499d 100644 --- a/calendar.go +++ b/calendar.go @@ -233,16 +233,17 @@ func (smr StringMatchRule) matchesString(data string) bool { } // check regex match if set if smr.RegexMatch != "" { - match, err := regexp.MatchString(data, smr.RegexMatch) + re, err := regexp.Compile(smr.RegexMatch) if err != nil { - slog.Warn("error processing regex rule", "value", smr.RegexMatch) - return false // regex error is considered a failure to match + slog.Warn("error processing regex rule", "value", smr.RegexMatch) + return false // regex error is considered a failure to match } + match := re.MatchString(data) if !match { - return false // regex didn't match + return false // regex didn't match } } - return true +return true } // EventTransformRules contains VEvent properties that user can modify