diff options
4 files changed, 11 insertions, 10 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java b/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java index e0a7e9481..fb6f0e520 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java @@ -548,7 +548,7 @@ public class EssentialsUpgrade try { - Thread.sleep(10000); + Thread.sleep(15000); } catch (InterruptedException ex) { @@ -595,7 +595,7 @@ public class EssentialsUpgrade countFiles++; - final String name = string.substring(0, string.length() - 4); + String name = string.substring(0, string.length() - 4); EssentialsUserConf config; UUID uuid = null; try @@ -609,7 +609,7 @@ public class EssentialsUpgrade conf.load(); conf.setProperty("lastAccountName", name); conf.save(); - + String uuidConf = ignoreUFCache ? "force-uuid" : "uuid"; String uuidString = conf.getString(uuidConf, null); diff --git a/Essentials/src/com/earth2me/essentials/UserMap.java b/Essentials/src/com/earth2me/essentials/UserMap.java index a615f753f..1e6b54c9b 100644 --- a/Essentials/src/com/earth2me/essentials/UserMap.java +++ b/Essentials/src/com/earth2me/essentials/UserMap.java @@ -84,7 +84,7 @@ public class UserMap extends CacheLoader<UUID, User> implements IConf { try { - final String sanitizedName = StringUtil.sanitizeFileName(name); + final String sanitizedName = StringUtil.safeString(name); if (names.containsKey(sanitizedName)) { final UUID uuid = names.get(sanitizedName); @@ -93,7 +93,7 @@ public class UserMap extends CacheLoader<UUID, User> implements IConf for (Player player : ess.getServer().getOnlinePlayers()) { - String sanitizedPlayer = StringUtil.sanitizeFileName(player.getName()); + String sanitizedPlayer = StringUtil.safeString(player.getName()); if (sanitizedPlayer.equalsIgnoreCase(sanitizedName)) { User user = new User(player, ess); @@ -144,7 +144,7 @@ public class UserMap extends CacheLoader<UUID, User> implements IConf keys.add(uuid); if (name != null && name.length() > 0) { - final String keyName = StringUtil.sanitizeFileName(name); + final String keyName = StringUtil.safeString(name); if (!names.containsKey(keyName) || !names.get(keyName).equals(uuid)) { names.put(keyName, uuid); @@ -195,7 +195,7 @@ public class UserMap extends CacheLoader<UUID, User> implements IConf users.invalidate(uuid); } names.remove(name); - names.remove(StringUtil.sanitizeFileName(name)); + names.remove(StringUtil.safeString(name)); } public Set<UUID> getAllUniqueUsers() diff --git a/Essentials/src/com/earth2me/essentials/api/Economy.java b/Essentials/src/com/earth2me/essentials/api/Economy.java index f0c46f860..309e8a628 100644 --- a/Essentials/src/com/earth2me/essentials/api/Economy.java +++ b/Essentials/src/com/earth2me/essentials/api/Economy.java @@ -51,6 +51,7 @@ public class Economy private static void createNPCFile(String name) { File folder = new File(ess.getDataFolder(), "userdata"); + name = StringUtil.safeString(name); if (!folder.exists()) { folder.mkdirs(); @@ -450,4 +451,3 @@ public class Economy deleteNPC(name); } } - diff --git a/Essentials/src/com/earth2me/essentials/utils/StringUtil.java b/Essentials/src/com/earth2me/essentials/utils/StringUtil.java index 3c0ea9239..6bb91313e 100644 --- a/Essentials/src/com/earth2me/essentials/utils/StringUtil.java +++ b/Essentials/src/com/earth2me/essentials/utils/StringUtil.java @@ -7,18 +7,19 @@ import java.util.regex.Pattern; public class StringUtil { private static final Pattern INVALIDFILECHARS = Pattern.compile("[^a-z0-9-]"); + private static final Pattern STRICTINVALIDCHARS = Pattern.compile("[^a-z0-9]"); private static final Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]"); //Used to clean file names before saving to disk public static String sanitizeFileName(final String name) { - return safeString(name); + return INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_"); } //Used to clean strings/names before saving as filenames/permissions public static String safeString(final String string) { - return INVALIDFILECHARS.matcher(string.toLowerCase(Locale.ENGLISH)).replaceAll("_"); + return STRICTINVALIDCHARS.matcher(string.toLowerCase(Locale.ENGLISH)).replaceAll("_"); } //Less restrictive string sanitizing, when not used as perm or filename |