From 8609f68f256684fe0cb190800a4e4437d15961ff Mon Sep 17 00:00:00 2001 From: xuxuck Date: Wed, 12 Aug 2020 14:37:09 +0200 Subject: [PATCH] Folder names remain closer to their original name. Fixes #1258 --- src/main/java/com/rarchives/ripme/utils/Utils.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/rarchives/ripme/utils/Utils.java b/src/main/java/com/rarchives/ripme/utils/Utils.java index a009c7a1..ba2a799b 100644 --- a/src/main/java/com/rarchives/ripme/utils/Utils.java +++ b/src/main/java/com/rarchives/ripme/utils/Utils.java @@ -486,8 +486,15 @@ public class Utils { return text; } + /** + * Removes any potentially unsafe characters from a string and truncates it on a maximum length of 100 characters. + * Characters considered safe are alpha numerical characters as well as minus, dot, comma, underscore and whitespace. + * + * @param text The potentially unsafe text + * @return a filesystem safe string + */ public static String filesystemSafe(String text) { - text = text.replaceAll("[^a-zA-Z0-9.-]", "_").replaceAll("__", "_").replaceAll("_+$", ""); + text = text.replaceAll("[^a-zA-Z0-9-.,_ ]", ""); if (text.length() > 100) { text = text.substring(0, 99); }