File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
main/java/org/springframework/web/util
test/java/org/springframework/web/util Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -578,7 +578,7 @@ private String removeJsessionid(String requestUri) {
578
578
return requestUri ;
579
579
}
580
580
String start = requestUri .substring (0 , index );
581
- for (int i = key .length (); i < requestUri .length (); i ++) {
581
+ for (int i = index + key .length (); i < requestUri .length (); i ++) {
582
582
char c = requestUri .charAt (i );
583
583
if (c == ';' || c == '/' ) {
584
584
return start + requestUri .substring (i );
Original file line number Diff line number Diff line change @@ -129,11 +129,19 @@ public void getRequestRemoveSemicolonContent() throws UnsupportedEncodingExcepti
129
129
public void getRequestKeepSemicolonContent () {
130
130
helper .setRemoveSemicolonContent (false );
131
131
132
- request .setRequestURI ("/foo;a=b;c=d" );
133
- assertThat (helper .getRequestUri (request )).isEqualTo ("/foo;a=b;c=d" );
134
-
135
- request .setRequestURI ("/foo;jsessionid=c0o7fszeb1" );
136
- assertThat (helper .getRequestUri (request )).isEqualTo ("/foo" );
132
+ testKeepSemicolonContent ("/foo;a=b;c=d" , "/foo;a=b;c=d" );
133
+ testKeepSemicolonContent ("/test;jsessionid=1234" , "/test" );
134
+ testKeepSemicolonContent ("/test;JSESSIONID=1234" , "/test" );
135
+ testKeepSemicolonContent ("/test;jsessionid=1234;a=b" , "/test;a=b" );
136
+ testKeepSemicolonContent ("/test;a=b;jsessionid=1234;c=d" , "/test;a=b;c=d" );
137
+ testKeepSemicolonContent ("/test;jsessionid=1234/anotherTest" , "/test/anotherTest" );
138
+ testKeepSemicolonContent ("/test;jsessionid=;a=b" , "/test;a=b" );
139
+ testKeepSemicolonContent ("/somethingLongerThan12;jsessionid=1234" , "/somethingLongerThan12" );
140
+ }
141
+
142
+ private void testKeepSemicolonContent (String requestUri , String expectedPath ) {
143
+ request .setRequestURI (requestUri );
144
+ assertThat (helper .getRequestUri (request )).isEqualTo (expectedPath );
137
145
}
138
146
139
147
@ Test
You can’t perform that action at this time.
0 commit comments