summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Schepp <schneeleo@gmail.com>2012-10-01 09:12:35 -0700
committerAlexander Schepp <schneeleo@gmail.com>2012-10-01 09:12:35 -0700
commitc576af4d8f60ce0d04480eca460f5deb5a1e1bc3 (patch)
treea1f83c3a58869cd60754a45813d8c26fa4ba030a
parente44d0754b55aac9b07af289eee18ecd4d0022a01 (diff)
parent6aad42e35eb0a51975fd00d1e9c5f922f06dae20 (diff)
downloadEssentials-c576af4d8f60ce0d04480eca460f5deb5a1e1bc3.tar
Essentials-c576af4d8f60ce0d04480eca460f5deb5a1e1bc3.tar.gz
Essentials-c576af4d8f60ce0d04480eca460f5deb5a1e1bc3.tar.lz
Essentials-c576af4d8f60ce0d04480eca460f5deb5a1e1bc3.tar.xz
Essentials-c576af4d8f60ce0d04480eca460f5deb5a1e1bc3.zip
Merge pull request #170 from chrisgward/2.9
Fixing storage of compiled regex
-rw-r--r--Essentials/src/com/earth2me/essentials/Util.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java
index 72c1accef..34e5c6420 100644
--- a/Essentials/src/com/earth2me/essentials/Util.java
+++ b/Essentials/src/com/earth2me/essentials/Util.java
@@ -23,11 +23,12 @@ 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 BADFILENAMES = Pattern.compile("^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\\.(.+))?$", Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.COMMENTS);
public static String sanitizeFileName(final String name)
{
String newName = INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
- if(Pattern.compile("^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\\.(.+))?$", Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.COMMENTS).matcher(newName).matches())
+ if(BADFILENAMES.matcher(newName).matches())
newName = "_" + newName;
return newName;
}