diff options
author | Chris Ward <chris@chrisgward.com> | 2012-10-01 21:20:17 +1000 |
---|---|---|
committer | Chris Ward <chris@chrisgward.com> | 2012-10-01 21:20:17 +1000 |
commit | 02d273f15ea40ee3a79239246d659eb534ed106e (patch) | |
tree | 452ac859db93e4278b5dcb4cc03e34e8d511526d | |
parent | d436d10b0031728315a3ebdec3560b7f432b7182 (diff) | |
download | Essentials-02d273f15ea40ee3a79239246d659eb534ed106e.tar Essentials-02d273f15ea40ee3a79239246d659eb534ed106e.tar.gz Essentials-02d273f15ea40ee3a79239246d659eb534ed106e.tar.lz Essentials-02d273f15ea40ee3a79239246d659eb534ed106e.tar.xz Essentials-02d273f15ea40ee3a79239246d659eb534ed106e.zip |
Fixing bad file names in Windows (Fixes #2924)
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Util.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index c1f7cd014..72c1accef 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -26,7 +26,9 @@ public class Util public static String sanitizeFileName(final String name) { - final String newName = INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_"); + 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()) + newName = "_" + newName; return newName; } |