Fix path matching for paths containing spaces
Prior to this commit, the latest optimizations introduced in SPR-13913 would prevent matching when patterns contained spaces. Indeed, the optimized path would not fully tokenize the paths nor trim the tokens, as the "longer" code path does. This commit disables this optimized path when the `trimTokens` option is set to `true`. Also, the `trimTokens` setting is now set to `false` by default. Issue: SPR-14247
This commit is contained in:
@@ -83,7 +83,7 @@ public class AntPathMatcher implements PathMatcher {
|
||||
|
||||
private boolean caseSensitive = true;
|
||||
|
||||
private boolean trimTokens = true;
|
||||
private boolean trimTokens = false;
|
||||
|
||||
private volatile Boolean cachePatterns;
|
||||
|
||||
@@ -314,19 +314,21 @@ public class AntPathMatcher implements PathMatcher {
|
||||
}
|
||||
|
||||
private boolean isPotentialMatch(String path, String[] pattDirs) {
|
||||
char[] pathChars = path.toCharArray();
|
||||
int pos = 0;
|
||||
for (String pattDir : pattDirs) {
|
||||
int skipped = skipSeparator(path, pos, this.pathSeparator);
|
||||
pos += skipped;
|
||||
skipped = skipSegment(pathChars, pos, pattDir);
|
||||
if (skipped < pattDir.length()) {
|
||||
if (skipped > 0) {
|
||||
return true;
|
||||
if (!this.trimTokens) {
|
||||
char[] pathChars = path.toCharArray();
|
||||
int pos = 0;
|
||||
for (String pattDir : pattDirs) {
|
||||
int skipped = skipSeparator(path, pos, this.pathSeparator);
|
||||
pos += skipped;
|
||||
skipped = skipSegment(pathChars, pos, pattDir);
|
||||
if (skipped < pattDir.length()) {
|
||||
if (skipped > 0) {
|
||||
return true;
|
||||
}
|
||||
return (pattDir.length() > 0) && isWildcardChar(pattDir.charAt(0));
|
||||
}
|
||||
return (pattDir.length() > 0) && isWildcardChar(pattDir.charAt(0));
|
||||
pos += skipped;
|
||||
}
|
||||
pos += skipped;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user