diff options
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Util.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index 65077a7fc..c6df66165 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -22,11 +22,17 @@ public class Util } private final static Logger logger = Logger.getLogger("Minecraft"); private final static Pattern INVALIDFILECHARS = Pattern.compile("[^a-z0-9]"); - private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");; + private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]"); + private static Map<String,String> sanitizedName = new HashMap<String,String>(); public static String sanitizeFileName(final String name) { - return INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_"); + if (sanitizedName.containsKey(name)) { + return sanitizedName.get(name); + } + final String newName = INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_"); + sanitizedName.put(name, newName); + return newName; } public static String sanitizeString(final String string) |