Description
Stéphane Nicoll opened SPR-11925 and commented
Decoding an URI can happen at two stages:
- The container may decode some part of the URI (some methods of
HttpServletRequest
do) - Spring MVC decodes the URI in various places. Most usage is centralized in
UrlPathHelper
though.
UrlPathHelper
defaults to ISO-8859-1
which is the default encoding defined in the spec. However if an encoding is set in the request, UrlPathHelper
uses such encoding to decode the URI.
Mixing different encodings for those stages lead to problems that can be very hard to track. In the end, forcing the encoding to be the same at all levels is the solution that is widely used.
It seems that most people configure the container to use UTF-8
(if necessary) alongside CharacterEncodingFilter
. This filter sets the encoding of the request to a configurable value (here UTF-8
) which will ensure that all decoding steps use the same encoding
The purpose of this issue is to investigate how we could bring such support as a core feature of Spring MVC rather than a user-defined filter. Another investigation would be to see how we could support a different encoding for the URI and the body (i.e. the URI uses UTF-8
but the body is decoded by some other encoding because of the way the client encoded it)
Issue Links:
- URL which contain "%85" can't request [SPR-12104] #16720 URL which contain "%85" can't request ("duplicates")
- 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
- PathVariable encoding fails if request charset is not set [SPR-11474] #16099 PathVariable encoding fails if request charset is not set
2 votes, 4 watchers