Skip to content

Commit

Permalink
UrlPathHelper.removeJsessionid correctly appends remainder
Browse files Browse the repository at this point in the history
Closes gh-26079
  • Loading branch information
rstoyanchev committed Nov 16, 2020
1 parent 9107aed commit 4ff521d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ private String removeJsessionid(String requestUri) {
return requestUri;
}
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);
if (c == ';' || c == '/') {
return start + requestUri.substring(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,19 @@ public void getRequestRemoveSemicolonContent() throws UnsupportedEncodingExcepti
public void getRequestKeepSemicolonContent() {
helper.setRemoveSemicolonContent(false);

request.setRequestURI("/foo;a=b;c=d");
assertEquals("/foo;a=b;c=d", helper.getRequestUri(request));

request.setRequestURI("/foo;jsessionid=c0o7fszeb1");
assertEquals("/foo", helper.getRequestUri(request));
testKeepSemicolonContent("/foo;a=b;c=d", "/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");
}

private void testKeepSemicolonContent(String requestUri, String expectedPath) {
request.setRequestURI(requestUri);
assertEquals(expectedPath, helper.getRequestUri(request));
}

@Test
Expand Down

0 comments on commit 4ff521d

Please sign in to comment.