1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-31 10:11:46 +02:00

Fixing bad file names in Windows (Fixes #2924)

This commit is contained in:
Chris Ward
2012-10-01 21:20:17 +10:00
parent 8855d2525a
commit f4b45f5ca0

View File

@@ -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;
}