File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
main/java/org/springframework/util
test/java/org/springframework/util Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -621,7 +621,12 @@ public static String cleanPath(String path) {
621
621
String prefix = "" ;
622
622
if (prefixIndex != -1 ) {
623
623
prefix = pathToUse .substring (0 , prefixIndex + 1 );
624
- pathToUse = pathToUse .substring (prefixIndex + 1 );
624
+ if (prefix .contains ("/" )) {
625
+ prefix = "" ;
626
+ }
627
+ else {
628
+ pathToUse = pathToUse .substring (prefixIndex + 1 );
629
+ }
625
630
}
626
631
if (pathToUse .startsWith (FOLDER_SEPARATOR )) {
627
632
prefix = prefix + FOLDER_SEPARATOR ;
Original file line number Diff line number Diff line change @@ -299,6 +299,8 @@ public void testCleanPath() {
299
299
assertEquals ("../mypath/myfile" , StringUtils .cleanPath ("../mypath/../mypath/myfile" ));
300
300
assertEquals ("../mypath/myfile" , StringUtils .cleanPath ("mypath/../../mypath/myfile" ));
301
301
assertEquals ("/../mypath/myfile" , StringUtils .cleanPath ("/../mypath/myfile" ));
302
+ assertEquals ("/mypath/myfile" , StringUtils .cleanPath ("/a/:b/../../mypath/myfile" ));
303
+ assertEquals ("file:///c:/path/to/the%20file.txt" , StringUtils .cleanPath ("file:///c:/some/../path/to/the%20file.txt" ));
302
304
}
303
305
304
306
public void testPathEquals () {
You can’t perform that action at this time.
0 commit comments