From 48f1e09a3607430af0c4be7baa898dfaea6cf7bb Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Wed, 29 Sep 2021 09:41:35 -0400 Subject: [PATCH] Making sure file names don't have spaces at the end --- Core/src/org/sleuthkit/autopsy/coreutils/FileUtil.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/FileUtil.java b/Core/src/org/sleuthkit/autopsy/coreutils/FileUtil.java index 29277217bf..1fe67dcd3f 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/FileUtil.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/FileUtil.java @@ -169,8 +169,9 @@ public class FileUtil { public static String escapeFileName(String fileName) { //for now escaping /:"*?<>| (not valid in file name, at least on Windows) //with underscores. We are only keeping \ as it could be part of the path. - return fileName.replaceAll("[\\p{Cntrl}/:\"*?<>|]+", "_"); - } + // Also trim empty space characters at the end of file name. + return fileName.replaceAll("[\\p{Cntrl}/:\"*?<>|]+", "_").trim(); + } /** * Test if the current user has read and write access to the dirPath.