-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: LINQ
-
None
-
None
-
Dotnet Drivers
-
None
-
None
-
None
-
None
-
None
-
None
When a char[] passed to String.IndexOfAny in a LINQ Where filter is empty or null, StringExpressionToRegexFilterTranslator emits a malformed character class. anyOf.Length == 0 skips the single-character branch and falls into the else at StringExpressionToRegexFilterTranslator.cs:607, which emits [
] with an empty set. A null array throws from the foreach in EscapeCharacterSet.
x.Str.IndexOfAny(Array.Empty<char>()) == 0 rendered as ^[] and causes server error: "Regular expression is invalid: missing terminating ] for character class."
x.Str.IndexOfAny(null) == 0 failed client-side with NullReferenceException.
Expected results: IndexOfAny with an empty array always returns -1, so comparison should match no documents.