Vera Straube created FOP-2857:
---------------------------------
Summary: FontCache.toDirectory(String path) returns a file object
that is not a directory
Key: FOP-2857
URL: https://issues.apache.org/jira/browse/FOP-2857
Project: FOP
Issue Type: Bug
Components: font/unqualified
Affects Versions: 2.3
Reporter: Vera Straube
The java.io.File instance represents a file or directory in the real filesystem.
The function checks only, if the file or directory exists.
I added checks for Nullpointer and if it is a directory.
The function checks the path parameter not strong enough.
I added a check for empty string or a string that contains only whitespaces.
//wrong code
private static File toDirectory(String path) {
if (path != null) {
File dir = new File(path);
if (dir.exists()) {
return dir;
}
}
return null;
}
//correct code
private static File toDirectory(String path) {
if (path != null && !path.trim().isEmpty()) {
//path is a non empty string
File dir = new File(path);
if (dir!=null && dir.exists() && dir.isDirectory()) {
//dir exists in the real fileystem and is a directory
return dir;
}
}
return null;
}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)