File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
main/java/org/springframework/web/util
test/java/org/springframework/web/util Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -405,17 +405,18 @@ else if (index1 == requestUri.length()) {
405
405
* </ul>
406
406
*/
407
407
private static String getSanitizedPath (final String path ) {
408
- if (path .length () == 0 ) {
408
+ int start = path .indexOf ("//" );
409
+ if (start == -1 ) {
409
410
return path ;
410
411
}
411
- char [] arr = path .toCharArray ();
412
- int slowIndex = 0 ;
413
- for (int fastIndex = 1 ; fastIndex < arr .length ; fastIndex ++) {
414
- if (arr [fastIndex ] != '/' || arr [slowIndex ] != '/' ) {
415
- arr [++slowIndex ] = arr [fastIndex ];
412
+ char [] content = path .toCharArray ();
413
+ int slowIndex = start ;
414
+ for (int fastIndex = start + 1 ; fastIndex < content .length ; fastIndex ++) {
415
+ if (content [fastIndex ] != '/' || content [slowIndex ] != '/' ) {
416
+ content [++slowIndex ] = content [fastIndex ];
416
417
}
417
418
}
418
- return new String (arr , 0 , slowIndex + 1 );
419
+ return new String (content , 0 , slowIndex + 1 );
419
420
}
420
421
421
422
/**
Original file line number Diff line number Diff line change @@ -232,12 +232,12 @@ void removeDuplicateSlashesInPath() {
232
232
request .setContextPath ("/SPR-12372" );
233
233
request .setPathInfo (null );
234
234
request .setServletPath ("/foo/bar/" );
235
- request .setRequestURI ("/SPR-12372/foo//bar/" );
235
+ request .setRequestURI ("/SPR-12372/foo/// bar/" );
236
236
237
237
assertThat (helper .getLookupPathForRequest (request )).isEqualTo ("/foo/bar/" );
238
238
239
239
request .setServletPath ("/foo/bar/" );
240
- request .setRequestURI ("/SPR-12372/foo/bar//" );
240
+ request .setRequestURI ("//// SPR-12372/foo/bar//" );
241
241
242
242
assertThat (helper .getLookupPathForRequest (request )).isEqualTo ("/foo/bar/" );
243
243
You can’t perform that action at this time.
0 commit comments