CommonsMultipartFile removes mixed separator paths from original filename

Issue: SPR-13662
This commit is contained in:
Juergen Hoeller
2015-11-10 23:43:40 +01:00
parent e6b1f0a139
commit 5d9d88c44d
2 changed files with 8 additions and 7 deletions

View File

@@ -78,12 +78,13 @@ public class CommonsMultipartFile implements MultipartFile, Serializable {
// Should never happen.
return "";
}
// Check for Unix-style path
int pos = filename.lastIndexOf("/");
if (pos == -1) {
// Check for Windows-style path
pos = filename.lastIndexOf("\\");
}
int unixSep = filename.lastIndexOf("/");
// Check for Windows-style path
int winSep = filename.lastIndexOf("\\");
// Cut off at latest possible point
int pos = (winSep > unixSep ? winSep : unixSep);
if (pos != -1) {
// Any sort of path separator found...
return filename.substring(pos + 1);