Closed
Description
Ivan Stojić opened SPR-12569 and commented
Flash attributes don't seem to be working when redirecting to a URL with query parameters which contain spaces (which get encoded as a '+' character), e.g. /test?param=hello+there .
I've created a simple Spring Boot (1.2.0) application which can be used to test this issue:
@EnableAutoConfiguration
@Controller
public class DemoApplication {
@RequestMapping("/")
@ResponseBody
String hello(ModelMap model) {
String name = (String)model.getOrDefault("name", "???");
return "Hello, " + name + "!";
}
@RequestMapping("/test1") // OK
String test1(RedirectAttributes redir) {
redir.addFlashAttribute("name", "World");
return "redirect:/";
}
@RequestMapping("/test2") // OK
String test2(RedirectAttributes redir) {
redir.addFlashAttribute("name", "World");
return "redirect:/?param=1";
}
@RequestMapping("/test3") // NOT WORKING
String test3(RedirectAttributes redir) {
redir.addFlashAttribute("name", "World");
return "redirect:/?param=1+2";
}
@RequestMapping("/test4") // NOT WORKING
String test4(RedirectAttributes redir) {
redir.addFlashAttribute("name", "World");
redir.addAttribute("param", "1 2");
return "redirect:/";
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
Affects: 4.1.3
Issue Links:
- Unable to retrieve FlashMap when contains "+"(half-space) in the request parameters [SPR-11821] #16441 Unable to retrieve FlashMap when contains "+"(half-space) in the request parameters ("is duplicated by")
- flash attributes not mapped from session to request scope when parameter value is url encoded [SPR-12986] #17577 flash attributes not mapped from session to request scope when parameter value is url encoded ("is duplicated by")
- Flashmap matching logic fails when target params are encoded. [SPR-9657] #14291 Flashmap matching logic fails when target params are encoded.
- Unable to retrieve FlashMap when target parameters are encoded [SPR-11504] #16129 Unable to retrieve FlashMap when target parameters are encoded
Referenced from: commits spring-attic/spring-framework-issues@3b66b10, spring-attic/spring-framework-issues@7cd7012