UrlPathHelper.removeJsessionid correctly appends remainder
Closes gh-26079
This commit is contained in:
parent
42d3bc47c9
commit
204a7fe91f
|
@ -635,7 +635,7 @@ public class UrlPathHelper {
|
||||||
return requestUri;
|
return requestUri;
|
||||||
}
|
}
|
||||||
String start = requestUri.substring(0, index);
|
String start = requestUri.substring(0, index);
|
||||||
for (int i = key.length(); i < requestUri.length(); i++) {
|
for (int i = index + key.length(); i < requestUri.length(); i++) {
|
||||||
char c = requestUri.charAt(i);
|
char c = requestUri.charAt(i);
|
||||||
if (c == ';' || c == '/') {
|
if (c == ';' || c == '/') {
|
||||||
return start + requestUri.substring(i);
|
return start + requestUri.substring(i);
|
||||||
|
|
|
@ -128,11 +128,19 @@ public class UrlPathHelperTests {
|
||||||
public void getRequestKeepSemicolonContent() {
|
public void getRequestKeepSemicolonContent() {
|
||||||
helper.setRemoveSemicolonContent(false);
|
helper.setRemoveSemicolonContent(false);
|
||||||
|
|
||||||
request.setRequestURI("/foo;a=b;c=d");
|
testKeepSemicolonContent("/foo;a=b;c=d", "/foo;a=b;c=d");
|
||||||
assertThat(helper.getRequestUri(request)).isEqualTo("/foo;a=b;c=d");
|
testKeepSemicolonContent("/test;jsessionid=1234", "/test");
|
||||||
|
testKeepSemicolonContent("/test;JSESSIONID=1234", "/test");
|
||||||
|
testKeepSemicolonContent("/test;jsessionid=1234;a=b", "/test;a=b");
|
||||||
|
testKeepSemicolonContent("/test;a=b;jsessionid=1234;c=d", "/test;a=b;c=d");
|
||||||
|
testKeepSemicolonContent("/test;jsessionid=1234/anotherTest", "/test/anotherTest");
|
||||||
|
testKeepSemicolonContent("/test;jsessionid=;a=b", "/test;a=b");
|
||||||
|
testKeepSemicolonContent("/somethingLongerThan12;jsessionid=1234", "/somethingLongerThan12");
|
||||||
|
}
|
||||||
|
|
||||||
request.setRequestURI("/foo;jsessionid=c0o7fszeb1");
|
private void testKeepSemicolonContent(String requestUri, String expectedPath) {
|
||||||
assertThat(helper.getRequestUri(request)).isEqualTo("/foo");
|
request.setRequestURI(requestUri);
|
||||||
|
assertThat(helper.getRequestUri(request)).isEqualTo(expectedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue