"Applied fix from trunk for revision: 1864930"
------------------------------------------------------------------------ r1864930 | jleroux | 2019-08-11 15:23:19 +0200 (dim. 11 août 2019) | 4 lignes Fixed: [FB] Find Security Bugs (OFBIZ-9973) As suggested by Mathieu on dev ML factorises the use of Path::normalize ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release17.12@1864932 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -401,4 +401,17 @@ public final class FileUtil {
|
||||
File f = new File(fileName);
|
||||
return f.isFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a File with a normalized file path
|
||||
* This useful to prevent path traversal security issues
|
||||
* cf. OFBIZ-9973 for more details
|
||||
*
|
||||
* @param filePath The file path to normalize
|
||||
* @return A File with a normalized file path
|
||||
*/
|
||||
public static File normalizeFilePath(String filePath) {
|
||||
return new File(filePath).toPath().normalize().toFile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user