mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 17:47:34 +01:00
Remove '-' from valid account names again.
This could cause issues with NPC's converted to UUID before this version.
This commit is contained in:
parent
04666b66b4
commit
c12373bf41
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user