From 0ae7161b475f76c500993bd9f418a12da9786ae8 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 10 Aug 2016 21:00:27 +0800 Subject: [PATCH] Strip newline characters from format expression results --- source/net/filebot/format/ExpressionFormat.java | 3 ++- source/net/filebot/util/RegularExpressions.java | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/source/net/filebot/format/ExpressionFormat.java b/source/net/filebot/format/ExpressionFormat.java index 05b95461..5b55df50 100644 --- a/source/net/filebot/format/ExpressionFormat.java +++ b/source/net/filebot/format/ExpressionFormat.java @@ -3,6 +3,7 @@ package net.filebot.format; import static net.filebot.similarity.Normalization.*; import static net.filebot.util.ExceptionUtilities.*; import static net.filebot.util.FileUtilities.*; +import static net.filebot.util.RegularExpressions.*; import java.security.AccessController; import java.text.FieldPosition; @@ -212,7 +213,7 @@ public class ExpressionFormat extends Format { } protected String normalizeResult(CharSequence value) { - return replaceSpace(value.toString(), " ").trim(); + return replaceSpace(NEWLINE.matcher(value).replaceAll(""), " ").trim(); } protected void handleException(ScriptException exception) { diff --git a/source/net/filebot/util/RegularExpressions.java b/source/net/filebot/util/RegularExpressions.java index eea8273f..a8db86b9 100644 --- a/source/net/filebot/util/RegularExpressions.java +++ b/source/net/filebot/util/RegularExpressions.java @@ -18,4 +18,6 @@ public class RegularExpressions { public static final Pattern SLASH = compile("\\s*[\\\\/]+\\s*", UNICODE_CHARACTER_CLASS); public static final Pattern SPACE = compile("\\s+", UNICODE_CHARACTER_CLASS); // French No-Break Space U+00A0 + public static final Pattern NEWLINE = compile("\\R+", UNICODE_CHARACTER_CLASS); + }