Skip to content
Snippets Groups Projects
Commit 46619051 authored by srosse's avatar srosse
Browse files

OO-2278: hardened the file suffix method against null or empty file names

parent 30970791
No related branches found
No related tags found
No related merge requests found
......@@ -792,10 +792,12 @@ public class FileUtils {
* @return return empty String "" without suffix.
*/
public static String getFileSuffix(String filePath) {
int lastDot = filePath.lastIndexOf('.');
if (lastDot > 0) {
if (lastDot < filePath.length())
return filePath.substring(lastDot + 1).toLowerCase();
if(StringHelper.containsNonWhitespace(filePath)) {
int lastDot = filePath.lastIndexOf('.');
if (lastDot > 0) {
if (lastDot < filePath.length())
return filePath.substring(lastDot + 1).toLowerCase();
}
}
return "";
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment