Revert "Improve suffix pattern check"
This reverts commit 3474afb165.
Unfortunately this change is likely to cause issues for applications
that use regular expressions in a URI variable. I think we will have
to leave at: if there are any dots in the last segment of the
request path, regardless of whether they're in a URI var or not,
the suffix pattern match is off.
Issue: SPR-11532
This commit is contained in:
@@ -249,7 +249,8 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!hasSuffix(pattern) && this.pathMatcher.match(pattern + ".*", lookupPath)) {
|
||||
boolean hasSuffix = pattern.indexOf('.') != -1;
|
||||
if (!hasSuffix && this.pathMatcher.match(pattern + ".*", lookupPath)) {
|
||||
return pattern + ".*";
|
||||
}
|
||||
}
|
||||
@@ -265,28 +266,6 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean hasSuffix(String pattern) {
|
||||
boolean uriVarMode = false;
|
||||
for (int i = pattern.length(); i > 0; i--) {
|
||||
char c = pattern.charAt(i-1);
|
||||
if (c == '}') {
|
||||
uriVarMode = true;
|
||||
}
|
||||
else if (c == '{') {
|
||||
uriVarMode = false;
|
||||
}
|
||||
else if (c == '/') {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if (!uriVarMode && c == '.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the two conditions based on the URL patterns they contain.
|
||||
* Patterns are compared one at a time, from top to bottom via
|
||||
|
||||
Reference in New Issue
Block a user