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:
committed by
Sam Brannen
parent
639a254e0d
commit
84200f3141
@@ -169,6 +169,9 @@ public class AntPathMatcher implements PathMatcher {
|
||||
|
||||
@Override
|
||||
public boolean isPattern(String path) {
|
||||
if(path == null) {
|
||||
return false;
|
||||
}
|
||||
boolean uriVar = false;
|
||||
for (int i = 0; i < path.length(); i++) {
|
||||
char c = path.charAt(i);
|
||||
@@ -207,7 +210,7 @@ public class AntPathMatcher implements PathMatcher {
|
||||
protected boolean doMatch(String pattern, String path, boolean fullMatch,
|
||||
@Nullable Map<String, String> uriTemplateVariables) {
|
||||
|
||||
if (path.startsWith(this.pathSeparator) != pattern.startsWith(this.pathSeparator)) {
|
||||
if (path == null || path.startsWith(this.pathSeparator) != pattern.startsWith(this.pathSeparator)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user