-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Christopher Kluwe opened SPR-7427 and commented
When a redirect URL(-Template) contains a UTF-8 encoded Identifier (e.g. /products/{productName}), it is sent back unencoded to the User Agent. Even using CharacterEncodingFilter with force-encoding enabled there is no Content-Type header in the response. So the User-Agent expects an ISO-8859-1 or US-ASCII encoded URL, urlencodes and requests it. Expecting a UTF8 encoded URL (through CharacterEncodingFilter), Spring decodes this path segment with a wrong encoding.
There are two possible solutions:
- I need to determine the character encoding of the response and call UriUtils.encodePathSegment for every critical path segment
- RedirectView calls UriUtils.encodePath itself
I've spent some thought on this and think that the second option is the way to go. The spring:url tag encodes the path parameters according to the response's encoding. To be consistent in this manner, RedirectView should do the same.
The appended simple change in RedirectView works fine for me, though I haven't run any Unit-Tests against it.
Affects: 3.0.3
Attachments:
- RedirectView.java.patch (624 bytes)
Issue Links:
- Problem with URL encoding in org.springframework.web.servlet.view.RedirectView.RedirectView(String url) [SPR-7490] #12148 Problem with URL encoding in org.springframework.web.servlet.view.RedirectView.RedirectView(String url)
- Regression in redirect URL encoding [SPR-7471] #12129 Regression in redirect URL encoding
Referenced from: commits 6e303d2