-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Case insensitive FastRegexMatcher doesn't check all folds #14066
Comments
A very quick diff that fixes the problem in the least performant way: diff --git model/labels/regexp.go model/labels/regexp.go
index 79e340984..7681483e7 100644
--- model/labels/regexp.go
+++ model/labels/regexp.go
@@ -791,7 +791,15 @@ func (m *equalMultiStringMapMatcher) Matches(s string) bool {
}
_, ok := m.values[s]
- return ok
+ if ok || m.caseSensitive {
+ return ok
+ }
+ for k := range m.values {
+ if strings.EqualFold(s, k) {
+ return true
+ }
+ }
+ return false
} |
I'd also consider just going through the standard regular expression engine if the matcher is case insensitive and the string contains unicode runes. |
The case-insensitive regular expression (Edit: this comment was a response to a deleted comment). |
you mean this matches function is incomplete right and it should have a check for a string to be matched . |
i think here we should use "regexp" package instead of "string" package . |
will create pr for this today . |
I observe it fails because Maybe we can use |
What did you do?
I ran the
mimir-prometheus
FuzzFastRegexMatcher_WithStaticallyDefinedRegularExpressions for a while, and found a bug.The input string
"ſſs"
is not matched by the case-insensitive regular expression"(?i:(foo1|foo2|aaa|bbb|ccc|ddd|eee|fff|ggg|hhh|iii|lll|mmm|nnn|ooo|ppp|qqq|rrr|sss|ttt|uuu|vvv|www|xxx|yyy|zzz))",
.What did you expect to see?
I expected that string to be matched, as the golang's regexp package matches it.
What did you see instead? Under which circumstances?
It wasn't matched.
The text was updated successfully, but these errors were encountered: