From 0b4730f070723baed4a2d2d55f7f02e2b63f29e7 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 10 Jan 2014 19:24:25 +0000 Subject: [PATCH] * make sure there's no double spaces left behind after stripping illegal characters --- source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy | 1 - source/net/sourceforge/tuned/FileUtilities.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy index cab680ba..8874a8a8 100644 --- a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy +++ b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy @@ -54,7 +54,6 @@ String.metaClass.getNameWithoutExtension = { getNameWithoutExtension(delegate) } String.metaClass.getExtension = { getExtension(delegate) } String.metaClass.hasExtension = { String... ext -> hasExtension(delegate, ext) } String.metaClass.validateFileName = { validateFileName(delegate) } -String.metaClass.validateFilePath = { validateFilePath(delegate) } // helper for enforcing filename length limits, e.g. truncate filename but keep extension String.metaClass.truncateFileName = { int limit = 255 -> def ext = getExtension(delegate); def name = getNameWithoutExtension(delegate); return name.substring(0, Math.min(limit - (ext ? 1+ext.length() : 0), name.length())) + (ext ? '.'+ext : '') } diff --git a/source/net/sourceforge/tuned/FileUtilities.java b/source/net/sourceforge/tuned/FileUtilities.java index fb25e3fa..c0edd252 100644 --- a/source/net/sourceforge/tuned/FileUtilities.java +++ b/source/net/sourceforge/tuned/FileUtilities.java @@ -471,7 +471,7 @@ public final class FileUtilities { */ public static String validateFileName(CharSequence filename) { // strip invalid characters from file name - return ILLEGAL_CHARACTERS.matcher(filename).replaceAll("").trim(); + return ILLEGAL_CHARACTERS.matcher(filename).replaceAll("").replaceAll("\\s+", " ").trim(); } public static boolean isInvalidFileName(CharSequence filename) {