Skip to content

URL in a redirect is not escaped by RedirectView [SPR-7427] #12085

@spring-projects-issues

Description

@spring-projects-issues

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:

  1. I need to determine the character encoding of the response and call UriUtils.encodePathSegment for every critical path segment
  2. 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:

Issue Links:

Referenced from: commits 6e303d2

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions