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()) {
405405 * </ul>
406406 */
407407 private static String getSanitizedPath (final String path ) {
408- if (path .length () == 0 ) {
408+ int start = path .indexOf ("//" );
409+ if (start == -1 ) {
409410 return path ;
410411 }
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 ];
416417 }
417418 }
418- return new String (arr , 0 , slowIndex + 1 );
419+ return new String (content , 0 , slowIndex + 1 );
419420 }
420421
421422 /**
Original file line number Diff line number Diff line change @@ -232,12 +232,12 @@ void removeDuplicateSlashesInPath() {
232232 request .setContextPath ("/SPR-12372" );
233233 request .setPathInfo (null );
234234 request .setServletPath ("/foo/bar/" );
235- request .setRequestURI ("/SPR-12372/foo//bar/" );
235+ request .setRequestURI ("/SPR-12372/foo/// bar/" );
236236
237237 assertThat (helper .getLookupPathForRequest (request )).isEqualTo ("/foo/bar/" );
238238
239239 request .setServletPath ("/foo/bar/" );
240- request .setRequestURI ("/SPR-12372/foo/bar//" );
240+ request .setRequestURI ("//// SPR-12372/foo/bar//" );
241241
242242 assertThat (helper .getLookupPathForRequest (request )).isEqualTo ("/foo/bar/" );
243243
You can’t perform that action at this time.
0 commit comments