Decode target parameter names prior to saving a FlashMap

In addition to the target parameter values (SPR-9657), the target
parameter names must also be decoded to be able to match
them to the parameter names of incoming requests.

Issue: SPR-11504
This commit is contained in:
Sebastien Deleuze 2014-03-06 03:30:04 +01:00 committed by Rossen Stoyanchev
parent 519799e1cf
commit 2f8bc6eec1
2 changed files with 4 additions and 1 deletions

View File

@ -219,7 +219,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
private void decodeParameters(MultiValueMap<String, String> params, HttpServletRequest request) {
for (String name : new ArrayList<String>(params.keySet())) {
for (String value : new ArrayList<String>(params.remove(name))) {
params.add(name, this.urlPathHelper.decodeRequestString(request, value));
params.add(this.urlPathHelper.decodeRequestString(request, name), this.urlPathHelper.decodeRequestString(request, value));
}
}
}

View File

@ -271,10 +271,13 @@ public class FlashMapManagerTests {
flashMap.addTargetRequestParam("key", "%D0%90%D0%90");
flashMap.addTargetRequestParam("key", "%D0%91%D0%91");
flashMap.addTargetRequestParam("key", "%D0%92%D0%92");
flashMap.addTargetRequestParam("%3A%2F%3F%23%5B%5D%40", "value");
this.flashMapManager.saveOutputFlashMap(flashMap, this.request, this.response);
assertEquals(Arrays.asList("\u0410\u0410", "\u0411\u0411", "\u0412\u0412"),
flashMap.getTargetRequestParams().get("key"));
assertEquals(Arrays.asList("value"),
flashMap.getTargetRequestParams().get(":/?#[]@"));
}