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:
@@ -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//");
|
||||
|
||||
Reference in New Issue
Block a user