|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2016 the original author or authors. |
|
|
|
* Copyright 2002-2017 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -220,8 +220,7 @@ public class AntPathMatcher implements PathMatcher { |
|
|
|
if (pathIdxStart > pathIdxEnd) { |
|
|
|
if (pathIdxStart > pathIdxEnd) { |
|
|
|
// Path is exhausted, only match if rest of pattern is * or **'s
|
|
|
|
// Path is exhausted, only match if rest of pattern is * or **'s
|
|
|
|
if (pattIdxStart > pattIdxEnd) { |
|
|
|
if (pattIdxStart > pattIdxEnd) { |
|
|
|
return (pattern.endsWith(this.pathSeparator) ? path.endsWith(this.pathSeparator) : |
|
|
|
return (pattern.endsWith(this.pathSeparator) == path.endsWith(this.pathSeparator)); |
|
|
|
!path.endsWith(this.pathSeparator)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (!fullMatch) { |
|
|
|
if (!fullMatch) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
@ -318,17 +317,13 @@ public class AntPathMatcher implements PathMatcher { |
|
|
|
|
|
|
|
|
|
|
|
private boolean isPotentialMatch(String path, String[] pattDirs) { |
|
|
|
private boolean isPotentialMatch(String path, String[] pattDirs) { |
|
|
|
if (!this.trimTokens) { |
|
|
|
if (!this.trimTokens) { |
|
|
|
char[] pathChars = path.toCharArray(); |
|
|
|
|
|
|
|
int pos = 0; |
|
|
|
int pos = 0; |
|
|
|
for (String pattDir : pattDirs) { |
|
|
|
for (String pattDir : pattDirs) { |
|
|
|
int skipped = skipSeparator(path, pos, this.pathSeparator); |
|
|
|
int skipped = skipSeparator(path, pos, this.pathSeparator); |
|
|
|
pos += skipped; |
|
|
|
pos += skipped; |
|
|
|
skipped = skipSegment(pathChars, pos, pattDir); |
|
|
|
skipped = skipSegment(path, pos, pattDir); |
|
|
|
if (skipped < pattDir.length()) { |
|
|
|
if (skipped < pattDir.length()) { |
|
|
|
if (skipped > 0) { |
|
|
|
return (skipped > 0 || (pattDir.length() > 0 && isWildcardChar(pattDir.charAt(0)))); |
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (pattDir.length() > 0) && isWildcardChar(pattDir.charAt(0)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
pos += skipped; |
|
|
|
pos += skipped; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -336,16 +331,18 @@ public class AntPathMatcher implements PathMatcher { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private int skipSegment(char[] chars, int pos, String prefix) { |
|
|
|
private int skipSegment(String path, int pos, String prefix) { |
|
|
|
int skipped = 0; |
|
|
|
int skipped = 0; |
|
|
|
for (char c : prefix.toCharArray()) { |
|
|
|
for (int i = 0; i < prefix.length(); i++) { |
|
|
|
|
|
|
|
char c = prefix.charAt(i); |
|
|
|
if (isWildcardChar(c)) { |
|
|
|
if (isWildcardChar(c)) { |
|
|
|
return skipped; |
|
|
|
return skipped; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (pos + skipped >= chars.length) { |
|
|
|
int currPos = pos + skipped; |
|
|
|
|
|
|
|
if (currPos >= path.length()) { |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (chars[pos + skipped] == c) { |
|
|
|
if (c == path.charAt(currPos)) { |
|
|
|
skipped++; |
|
|
|
skipped++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|