Treat null path as non-matching pattern in AntPathMatcher

Prior to this commit, a null path supplied to the isPattern(), match(),
and matchStart() methods in AntPathMatcher resulted in a
NullPointerException.

This commit addresses this by treating a `null` path as a non-matching
pattern.

Closes gh-23297
This commit is contained in:
Scheidter,Ryan
2019-07-16 08:06:02 -05:00
committed by Sam Brannen
parent 639a254e0d
commit 84200f3141
3 changed files with 46 additions and 1 deletions

View File

@@ -130,6 +130,11 @@ public class AntPathMatcherTests {
assertThat(pathMatcher.match("", "")).isTrue();
assertThat(pathMatcher.match("/{bla}.*", "/testing.html")).isTrue();
assertThat(pathMatcher.match("/test", null)).isFalse();
assertThat(pathMatcher.match("/", null)).isFalse();
assertThat(pathMatcher.match("/", null)).isFalse();
assertThat(pathMatcher.match(null, null)).isFalse();
}
// SPR-14247
@@ -688,6 +693,7 @@ public class AntPathMatcherTests {
assertThat(pathMatcher.isPattern("/test/{name}")).isTrue();
assertThat(pathMatcher.isPattern("/test/name")).isFalse();
assertThat(pathMatcher.isPattern("/test/foo{bar")).isFalse();
assertThat(pathMatcher.isPattern(null)).isFalse();
}
}