diff options
author | Chris Ward <chris@chrisgward.com> | 2012-10-02 02:11:05 +1000 |
---|---|---|
committer | Chris Ward <chris@chrisgward.com> | 2012-10-02 02:11:05 +1000 |
commit | 2757c707bbf3aca4918ef9978b786077db6882fa (patch) | |
tree | 2ba6c951261e5e91fe56c78cbf31b56635cb174f | |
parent | a7e692fe3721373aab5e43f5c0de4c729bfd931e (diff) | |
download | Essentials-2757c707bbf3aca4918ef9978b786077db6882fa.tar Essentials-2757c707bbf3aca4918ef9978b786077db6882fa.tar.gz Essentials-2757c707bbf3aca4918ef9978b786077db6882fa.tar.lz Essentials-2757c707bbf3aca4918ef9978b786077db6882fa.tar.xz Essentials-2757c707bbf3aca4918ef9978b786077db6882fa.zip |
Fixing storage of compiled regex
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Util.java | 3 |
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; } |