Skip to content

Better handling of URI encoding configuration [SPR-11925] #16543

Closed
@spring-projects-issues

Description

@spring-projects-issues

Stéphane Nicoll opened SPR-11925 and commented

Decoding an URI can happen at two stages:

  1. The container may decode some part of the URI (some methods of HttpServletRequest do)
  2. 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:

2 votes, 4 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: bulk-closedAn outdated, unresolved issue that's closed in bulk as part of a cleaning process

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions