SPR-8858 Fix in AntPathMatcher.combine(..)
Currently the combine method consolidates "/*" and "/hotel"
into "/hotel". However if the first pattern contains URI template
variables, the consolidation seems wrong. The fix is to prevent
the consolidation if the first pattern contains "{".
This commit is contained in:
@@ -299,7 +299,7 @@ public class AntPathMatcher implements PathMatcher {
|
||||
else if (!StringUtils.hasText(pattern2)) {
|
||||
return pattern1;
|
||||
}
|
||||
else if (match(pattern1, pattern2)) {
|
||||
else if (!pattern1.contains("{") && match(pattern1, pattern2)) {
|
||||
return pattern2;
|
||||
}
|
||||
else if (pattern1.endsWith("/*")) {
|
||||
|
||||
@@ -407,7 +407,10 @@ public class AntPathMatcherTests {
|
||||
assertEquals("/hotel.html", pathMatcher.combine("/*.html", "/hotel.html"));
|
||||
assertEquals("/hotel.html", pathMatcher.combine("/*.html", "/hotel"));
|
||||
assertEquals("/hotel.html", pathMatcher.combine("/*.html", "/hotel.*"));
|
||||
assertEquals("/*.html", pathMatcher.combine("/**", "/*.html"));
|
||||
assertEquals("/*.html", pathMatcher.combine("/*", "/*.html"));
|
||||
assertEquals("/*.html", pathMatcher.combine("/*.*", "/*.html"));
|
||||
assertEquals("/{foo}/bar", pathMatcher.combine("/{foo}", "/bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user