Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContentNegotiationViewResolver should not decode Request-URI while fetching requested Media-Types [SPR-9390] #14026

Closed
spring-projects-issues opened this issue May 9, 2012 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented May 9, 2012

Kai Moritz opened SPR-9390 and commented

Description:


If favorPathExtension is set, the ContentNegotiationViewResolver analyzes the URI of the request and adds a MediaType according to the path-extension.

While doing this, it uses the helper-function UrlPathHelper.getLookupPathForRequest(HttpRequest) to retrieve the URI.
This leads to errors, when the URI contains correctly encoded reserved characters, becaus this helper-function decodes the URI!

Consider the URI "/quo%20vadis%3f.html".
UrlPathHelper.getLookupPathForRequest(HttpRequest) decodes this to "/quo vadis?.html".
And because of the "?" the ContentNegotiationViewResolver thinks, that the URI is "/quo vadis" and adds the MediaType "*/*", which may lead to unexpected content negotiation results.

Fix:


Replace "urlPathHelper.getLookupPathForRequest(request)" with "request.getRequestURI()".
I have addes a patch, which does just this and fixes the problem for me.


Affects: 3.1.1

Attachments:

Referenced from: commits e04b322

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented May 10, 2012

Rossen Stoyanchev commented

I fixed this by setting the decode property of UrlPathHelper to false. Using request.getRequestURI() breaks another issue, see #13320.

@spring-projects-issues spring-projects-issues added type: bug A general bug in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.2 M1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants