From 2f8bc6eec12c997c335924cc81029bf67112c7e5 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Thu, 6 Mar 2014 03:30:04 +0100 Subject: [PATCH] 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 --- .../web/servlet/support/AbstractFlashMapManager.java | 2 +- .../web/servlet/support/FlashMapManagerTests.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/AbstractFlashMapManager.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/AbstractFlashMapManager.java index d667e88a819..568b4d9f96c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/AbstractFlashMapManager.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/AbstractFlashMapManager.java @@ -219,7 +219,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager { private void decodeParameters(MultiValueMap params, HttpServletRequest request) { for (String name : new ArrayList(params.keySet())) { for (String value : new ArrayList(params.remove(name))) { - params.add(name, this.urlPathHelper.decodeRequestString(request, value)); + params.add(this.urlPathHelper.decodeRequestString(request, name), this.urlPathHelper.decodeRequestString(request, value)); } } } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java index a76dd3b1caa..94e755d8142 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java @@ -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(":/?#[]@")); }