summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIaccidentally <coryhuckaby@gmail.com>2012-10-01 07:16:22 -0700
committerIaccidentally <coryhuckaby@gmail.com>2012-10-01 07:16:22 -0700
commita7e692fe3721373aab5e43f5c0de4c729bfd931e (patch)
tree452ac859db93e4278b5dcb4cc03e34e8d511526d
parentd7829bef2839de84fed8f2af5dd949e74070e8e2 (diff)
parent02d273f15ea40ee3a79239246d659eb534ed106e (diff)
downloadEssentials-a7e692fe3721373aab5e43f5c0de4c729bfd931e.tar
Essentials-a7e692fe3721373aab5e43f5c0de4c729bfd931e.tar.gz
Essentials-a7e692fe3721373aab5e43f5c0de4c729bfd931e.tar.lz
Essentials-a7e692fe3721373aab5e43f5c0de4c729bfd931e.tar.xz
Essentials-a7e692fe3721373aab5e43f5c0de4c729bfd931e.zip
Merge pull request #164 from chrisgward/patch-1
Fixing bad file names in Windows (Fixes #2924)
-rw-r--r--Essentials/src/com/earth2me/essentials/Util.java4
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;
}