-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[Tests] Handle escape char correctly in wildcard patterns #69850
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
Conversation
Pinging @elastic/es-security (Team:Security) |
@@ -26,10 +26,11 @@ public void testEmptySet() throws Exception { | |||
public void testSingleWildcard() throws Exception { | |||
final String prefix = randomAlphaOfLengthBetween(3, 5); | |||
final StringMatcher matcher = StringMatcher.of(prefix + "*"); | |||
final String normalisedPrefix = prefix.replace("\\", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefix
cannot contain a \
, it's alphabetic only.
@@ -48,10 +49,11 @@ public void testUnicodeWildcard() throws Exception { | |||
final String prefix = randomValueOtherThanMany(StringMatcherTests::hasHighSurrogate, | |||
() -> randomRealisticUnicodeOfLengthBetween(3, 5)); | |||
final StringMatcher matcher = StringMatcher.of(prefix + "*"); | |||
final String normalisedPrefix = prefix.replace("\\", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just push this up into the otherThanMany
check.
randomValueOtherThanMany(StringMatcherTests::hasHighSurrogateOrBackslash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated as suggested.
PS: I think we do need some tests for the behaviour of the escape char. This is not the right place for it. Maybe when fixing #69851.
Escape char is handled specially while building automaton. It should also be handled when buidling the target text for matching.
Resolves: #69837