-
Notifications
You must be signed in to change notification settings - Fork 154
Description
Since upgrade my project from spring boot 2.4.1 to 2.4.2 (with upgrade thymeleaf-spring5-3.0.12) there is a bug when post forms with input containing '%' character (for example : "%example%").
This bug was introduced with change in class ThymeleafView method renderFragment() and the call of checkViewNameNotInRequest() :
Controllers using Forms that have percent-encoded values that cannot be decoded (that is, "%example%") in them and the controller endpoint that processes the form returns a "view :: fragment".
java.lang.IllegalArgumentException: Incomplete escaping sequence in input at org.unbescape.uri.UriEscapeUtil.unescape(UriEscapeUtil.java:617) at org.unbescape.uri.UriEscape.unescapeUriQueryParam(UriEscape.java:1702) at org.unbescape.uri.UriEscape.unescapeUriQueryParam(UriEscape.java:1668) at org.thymeleaf.spring5.util.SpringRequestUtils.checkViewNameNotInRequest(SpringRequestUtils.java:55) at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:275) at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:190) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1373) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1057) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
At the time checkViewNameNotInRequest() is called, the request parameters are already unescaped and hence calling UriEscape.unescapeUriQueryParam()will fail for values that contain an invalid '%' escape sequence.