You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
org.springframework.web.servlet.support.DefaultFlashMapManager does not support URLs with multiple parameter values. Consider the following annotated methods that performs a redirect after a POST:
After the /test/ method is executed, the browser is redirected to the /?id=10&id=20 URL.
When DefaultFlashMapManager tries to match the FlashMap object in the session with the URL, it always fails since it just supports one value for parameter. In this case, it would not match the path since it would think 20 is not a valid value for parameter id.
This is the current code in 3.1 RC:
/**
Whether the given FlashMap matches the current request.
The default implementation uses the target request path and query params
Andrea opened SPR-8798 and commented
org.springframework.web.servlet.support.DefaultFlashMapManager does not support URLs with multiple parameter values. Consider the following annotated methods that performs a redirect after a POST:
After the /test/ method is executed, the browser is redirected to the /?id=10&id=20 URL.
When DefaultFlashMapManager tries to match the FlashMap object in the session with the URL, it always fails since it just supports one value for parameter. In this case, it would not match the path since it would think 20 is not a valid value for parameter id.
This is the current code in 3.1 RC:
/**
*/protected boolean isFlashMapForRequest(FlashMap flashMap, HttpServletRequest request) {if (flashMap.getTargetRequestPath() != null) {String requestUri = this.urlPathHelper.getRequestUri(request);if (!requestUri.equals(flashMap.getTargetRequestPath())
&& !requestUri.equals(flashMap.getTargetRequestPath() + "/")) {return false;
}
}
MultiValueMap<String, String> params = flashMap.getTargetRequestParams();for (String key : params.keySet()) {for (String value : params.get(key)) {if (!value.equals(request.getParameter(key))) {return false;
}
}
}return true;
}
The code should iterate through all values for a given parameter in the request before rejecting it:
protected boolean isFlashMapForRequest(FlashMap flashMap, HttpServletRequest request) {
if (flashMap.getTargetRequestPath() != null) {
String requestUri = this.urlPathHelper.getRequestUri(request);
if (!requestUri.equals(flashMap.getTargetRequestPath())
&& !requestUri.equals(flashMap.getTargetRequestPath() + "/")) {
return false;
}
}
MultiValueMap<String, String> params = flashMap.getTargetRequestParams();
for (String key : params.keySet()) {
// FIX FROM HERE... String requestValues[] = request.getParameterValues(key);
if (requestValues == null || requestValues.length == 0) {
return false;
}
}
Affects: 3.1 RC1
The text was updated successfully, but these errors were encountered: