Don't decode URI for content negotiation by extension
Minor bug fix in the ContentNegotiatingViewResolver where decoding the URI prevented proper detection of the file extension in a URL. Issue: SPR-9390
This commit is contained in:
@@ -117,6 +117,9 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport
|
|||||||
|
|
||||||
private static final UrlPathHelper urlPathHelper = new UrlPathHelper();
|
private static final UrlPathHelper urlPathHelper = new UrlPathHelper();
|
||||||
|
|
||||||
|
static {
|
||||||
|
urlPathHelper.setUrlDecode(false);
|
||||||
|
}
|
||||||
|
|
||||||
private int order = Ordered.HIGHEST_PRECEDENCE;
|
private int order = Ordered.HIGHEST_PRECEDENCE;
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,15 @@ public class ContentNegotiatingViewResolverTests {
|
|||||||
assertTrue("Context path should be excluded", viewResolver.getMediaTypes(request).isEmpty());
|
assertTrue("Context path should be excluded", viewResolver.getMediaTypes(request).isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SPR-9390
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMediaTypeFilenameWithEncodedURI() {
|
||||||
|
request.setRequestURI("/quo%20vadis%3f.html");
|
||||||
|
List<MediaType> result = viewResolver.getMediaTypes(request);
|
||||||
|
assertEquals("Invalid content type", Collections.singletonList(new MediaType("text", "html")), result);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMediaTypeParameter() {
|
public void getMediaTypeParameter() {
|
||||||
viewResolver.setFavorParameter(true);
|
viewResolver.setFavorParameter(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user