Handle possible regexes defensively in NamePatternFilter
Previously, if a name contained part of a regex but wasn't actually a regex, a PatternSyntaxException would be thrown and the request would fail. This commit updates NamePatternFilter to catch PatternSyntaxException and treat the regex-like input as a name insteead. See gh-9730
This commit is contained in:
@@ -27,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @author Dylian Bego
|
||||
*/
|
||||
public class NamePatternFilterTests {
|
||||
|
||||
@@ -38,6 +39,13 @@ public class NamePatternFilterTests {
|
||||
assertThat(filter.isGetNamesCalled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonRegexThatContainsRegexPart() throws Exception {
|
||||
MockNamePatternFilter filter = new MockNamePatternFilter();
|
||||
assertThat(filter.getResults("*")).containsEntry("*", "*");
|
||||
assertThat(filter.isGetNamesCalled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void regexRepetitionZeroOrMore() {
|
||||
MockNamePatternFilter filter = new MockNamePatternFilter();
|
||||
|
||||
Reference in New Issue
Block a user