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 @@ -622,7 +622,12 @@ public static String cleanPath(String path) {
622
622
String prefix = "" ;
623
623
if (prefixIndex != -1 ) {
624
624
prefix = pathToUse .substring (0 , prefixIndex + 1 );
625
- pathToUse = pathToUse .substring (prefixIndex + 1 );
625
+ if (prefix .contains ("/" )) {
626
+ prefix = "" ;
627
+ }
628
+ else {
629
+ pathToUse = pathToUse .substring (prefixIndex + 1 );
630
+ }
626
631
}
627
632
if (pathToUse .startsWith (FOLDER_SEPARATOR )) {
628
633
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