Throw exception using capturing patterns in AntPathMatcher
Closes gh-27688
This commit is contained in:
parent
29572600dc
commit
5fbdd6dcfe
|
@ -733,6 +733,10 @@ public class AntPathMatcher implements PathMatcher {
|
||||||
}
|
}
|
||||||
for (int i = 1; i <= matcher.groupCount(); i++) {
|
for (int i = 1; i <= matcher.groupCount(); i++) {
|
||||||
String name = this.variableNames.get(i - 1);
|
String name = this.variableNames.get(i - 1);
|
||||||
|
if (name.startsWith("*")) {
|
||||||
|
throw new IllegalArgumentException("Capturing patterns (" + name + ") are not " +
|
||||||
|
"supported by the AntPathMatcher. Use the PathPatternParser instead.");
|
||||||
|
}
|
||||||
String value = matcher.group(i);
|
String value = matcher.group(i);
|
||||||
uriTemplateVariables.put(name, value);
|
uriTemplateVariables.put(name, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,13 +155,15 @@ public class PathMatchingUrlHandlerMappingTests {
|
||||||
chain = getHandler(mapping, wac, request);
|
chain = getHandler(mapping, wac, request);
|
||||||
assertThat(chain.getHandler()).isSameAs(defaultBean);
|
assertThat(chain.getHandler()).isSameAs(defaultBean);
|
||||||
|
|
||||||
request = new MockHttpServletRequest("GET", "/administrator/testing/longer/bla");
|
if (mapping.getPatternParser() != null) {
|
||||||
chain = getHandler(mapping, wac, request);
|
request = new MockHttpServletRequest("GET", "/administrator/testing/longer/bla");
|
||||||
assertThat(chain.getHandler()).isSameAs(bean);
|
chain = getHandler(mapping, wac, request);
|
||||||
|
assertThat(chain.getHandler()).isSameAs(bean);
|
||||||
|
|
||||||
request = new MockHttpServletRequest("GET", "/administrator/testing/longer/test.jsp");
|
request = new MockHttpServletRequest("GET", "/administrator/testing/longer/test.jsp");
|
||||||
chain = getHandler(mapping, wac, request);
|
chain = getHandler(mapping, wac, request);
|
||||||
assertThat(chain.getHandler()).isSameAs(bean);
|
assertThat(chain.getHandler()).isSameAs(bean);
|
||||||
|
}
|
||||||
|
|
||||||
request = new MockHttpServletRequest("GET", "/administrator/testing/longer2/notmatching/notmatching");
|
request = new MockHttpServletRequest("GET", "/administrator/testing/longer2/notmatching/notmatching");
|
||||||
chain = getHandler(mapping, wac, request);
|
chain = getHandler(mapping, wac, request);
|
||||||
|
|
Loading…
Reference in New Issue