@@ -401,18 +401,17 @@ else if (index1 == requestUri.length()) {
401
401
* <li>replace all "//" by "/"</li>
402
402
* </ul>
403
403
*/
404
- private String getSanitizedPath (final String path ) {
405
- String sanitized = path ;
406
- while (true ) {
407
- int index = sanitized .indexOf ("//" );
408
- if (index < 0 ) {
409
- break ;
410
- }
411
- else {
412
- sanitized = sanitized .substring (0 , index ) + sanitized .substring (index + 1 );
404
+ private static String getSanitizedPath (final String path ) {
405
+ int index = path .indexOf ("//" );
406
+ if (index >= 0 ) {
407
+ StringBuilder sanitized = new StringBuilder (path );
408
+ while (index != -1 ) {
409
+ sanitized .deleteCharAt (index );
410
+ index = sanitized .indexOf ("//" , index );
413
411
}
412
+ return sanitized .toString ();
414
413
}
415
- return sanitized ;
414
+ return path ;
416
415
}
417
416
418
417
/**
@@ -612,15 +611,20 @@ public String removeSemicolonContent(String requestUri) {
612
611
removeSemicolonContentInternal (requestUri ) : removeJsessionid (requestUri ));
613
612
}
614
613
615
- private String removeSemicolonContentInternal (String requestUri ) {
614
+ private static String removeSemicolonContentInternal (String requestUri ) {
616
615
int semicolonIndex = requestUri .indexOf (';' );
616
+ if (semicolonIndex == -1 ) {
617
+ return requestUri ;
618
+ }
619
+ StringBuilder sb = new StringBuilder (requestUri );
617
620
while (semicolonIndex != -1 ) {
618
621
int slashIndex = requestUri .indexOf ('/' , semicolonIndex );
619
- String start = requestUri .substring (0 , semicolonIndex );
620
- requestUri = (slashIndex != -1 ) ? start + requestUri .substring (slashIndex ) : start ;
621
- semicolonIndex = requestUri .indexOf (';' , semicolonIndex );
622
+ if (slashIndex >= 0 ) {
623
+ sb .delete (semicolonIndex , slashIndex );
624
+ }
625
+ semicolonIndex = sb .indexOf (";" , semicolonIndex );
622
626
}
623
- return requestUri ;
627
+ return sb . toString () ;
624
628
}
625
629
626
630
private String removeJsessionid (String requestUri ) {
0 commit comments