Add missing URI template variables in RedirectViews
Prior to this commit, the URL handler mapping would expose the matching pattern, the path within mapping and matching URI variables as request attributes. This was the case when the mapping would use the `AntPathMatcher` as matching infrastructure, but not when using the `PathPattern` variant. In this case, the map of URI variables would be `null`. This could throw `IllegalArgumentException` when `RedirectView` instances were relying on the presence of specific variables. This commit ensures that URI variables are also extracted when the `PathPatternParser` is used. Fixes gh-33422
This commit is contained in:
@@ -219,7 +219,9 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
|
||||
validateHandler(handler, request);
|
||||
String pathWithinMapping = pattern.extractPathWithinPattern(path.pathWithinApplication()).value();
|
||||
pathWithinMapping = UrlPathHelper.defaultInstance.removeSemicolonContent(pathWithinMapping);
|
||||
return buildPathExposingHandler(handler, pattern.getPatternString(), pathWithinMapping, null);
|
||||
PathPattern.PathMatchInfo pathMatchInfo = pattern.matchAndExtract(path);
|
||||
Map<String, String> uriVariables = (pathMatchInfo != null ? pathMatchInfo.getUriVariables(): null);
|
||||
return buildPathExposingHandler(handler, pattern.getPatternString(), pathWithinMapping, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user