parent
b5743966d6
commit
c6ce65ef56
|
|
@ -405,17 +405,18 @@ public class UrlPathHelper {
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
private static String getSanitizedPath(final String path) {
|
private static String getSanitizedPath(final String path) {
|
||||||
if (path.length() == 0) {
|
int start = path.indexOf("//");
|
||||||
|
if (start == -1) {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
char[] arr = path.toCharArray();
|
char[] content = path.toCharArray();
|
||||||
int slowIndex = 0;
|
int slowIndex = start;
|
||||||
for (int fastIndex = 1; fastIndex < arr.length; fastIndex++) {
|
for (int fastIndex = start + 1; fastIndex < content.length; fastIndex++) {
|
||||||
if (arr[fastIndex] != '/' || arr[slowIndex] != '/') {
|
if (content[fastIndex] != '/' || content[slowIndex] != '/') {
|
||||||
arr[++slowIndex] = arr[fastIndex];
|
content[++slowIndex] = content[fastIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new String(arr, 0, slowIndex + 1);
|
return new String(content, 0, slowIndex + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -232,12 +232,12 @@ class UrlPathHelperTests {
|
||||||
request.setContextPath("/SPR-12372");
|
request.setContextPath("/SPR-12372");
|
||||||
request.setPathInfo(null);
|
request.setPathInfo(null);
|
||||||
request.setServletPath("/foo/bar/");
|
request.setServletPath("/foo/bar/");
|
||||||
request.setRequestURI("/SPR-12372/foo//bar/");
|
request.setRequestURI("/SPR-12372/foo///bar/");
|
||||||
|
|
||||||
assertThat(helper.getLookupPathForRequest(request)).isEqualTo("/foo/bar/");
|
assertThat(helper.getLookupPathForRequest(request)).isEqualTo("/foo/bar/");
|
||||||
|
|
||||||
request.setServletPath("/foo/bar/");
|
request.setServletPath("/foo/bar/");
|
||||||
request.setRequestURI("/SPR-12372/foo/bar//");
|
request.setRequestURI("////SPR-12372/foo/bar//");
|
||||||
|
|
||||||
assertThat(helper.getLookupPathForRequest(request)).isEqualTo("/foo/bar/");
|
assertThat(helper.getLookupPathForRequest(request)).isEqualTo("/foo/bar/");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue