Sanitize duplicate slashes in request path

This commit removes duplicate slashes in the resolved lookup path when
calling `UrlPathHelper.getLookupPathForRequest`. This is especially
necessary when the path is cleaned from semicolon content and leaves
duplicate slashes in the request path.

Issue: SPR-13455
This commit is contained in:
Brian Clozel
2015-10-08 11:05:51 +02:00
parent 15b88782f7
commit 758ae98af2
2 changed files with 12 additions and 4 deletions

View File

@@ -121,6 +121,13 @@ public class UrlPathHelperTests {
request.setRequestURI("/foo;f=F;o=O;o=O/bar;b=B;a=A;r=R");
assertEquals("/foo/bar", helper.getRequestUri(request));
// SPR-13455
request.setServletPath("/foo/1");
request.setRequestURI("/foo/;test/1");
assertEquals("/foo/1", helper.getRequestUri(request));
}
@Test
@@ -204,20 +211,20 @@ public class UrlPathHelperTests {
assertEquals("/foo/", helper.getLookupPathForRequest(request));
}
//SPR-12372
//SPR-12372 & SPR-13455
@Test
public void defaultServletEndingWithDoubleSlash() throws Exception {
public void removeDuplicateSlashesInPath() throws Exception {
request.setContextPath("/SPR-12372");
request.setPathInfo(null);
request.setServletPath("/foo/bar/");
request.setRequestURI("/SPR-12372/foo//bar/");
assertEquals("/foo//bar/", helper.getLookupPathForRequest(request));
assertEquals("/foo/bar/", helper.getLookupPathForRequest(request));
request.setServletPath("/foo/bar/");
request.setRequestURI("/SPR-12372/foo/bar//");
assertEquals("/foo/bar//", helper.getLookupPathForRequest(request));
assertEquals("/foo/bar/", helper.getLookupPathForRequest(request));
// "normal" case
request.setServletPath("/foo/bar//");