mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 01:27:40 +01:00
Sanitize mail for untoward characters.
Prevent a user error from terminating essentials timer task.
This commit is contained in:
parent
92fa415848
commit
5c19e71858
@ -3,6 +3,7 @@ package com.earth2me.essentials;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@ -22,10 +23,17 @@ public class EssentialsTimer implements Runnable
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
onlineUsers.add(user);
|
||||
user.setLastOnlineActivity(currentTime);
|
||||
user.checkActivity();
|
||||
try
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
onlineUsers.add(user);
|
||||
user.setLastOnlineActivity(currentTime);
|
||||
user.checkActivity();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ess.getLogger().log(Level.WARNING, "EssentialsTimer Error:", e);
|
||||
}
|
||||
}
|
||||
|
||||
final Iterator<User> iterator = onlineUsers.iterator();
|
||||
|
@ -21,11 +21,17 @@ public class Util
|
||||
{
|
||||
}
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private final static Pattern INVALIDCHARS = Pattern.compile("[^a-z0-9]");
|
||||
private final static Pattern INVALIDFILECHARS = Pattern.compile("[^a-z0-9]");
|
||||
private final static Pattern INVALIDCHARS = Pattern.compile("[^\\p{Print}]");
|
||||
|
||||
public static String sanitizeFileName(final String name)
|
||||
{
|
||||
return INVALIDCHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
|
||||
return INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
|
||||
}
|
||||
|
||||
public static String sanitizeString(final String string)
|
||||
{
|
||||
return INVALIDCHARS.matcher(string).replaceAll("");
|
||||
}
|
||||
|
||||
public static String formatDateDiff(long date)
|
||||
|
@ -40,7 +40,7 @@ public class Commandmail extends EssentialsCommand
|
||||
{
|
||||
if (!user.isAuthorized("essentials.mail.send"))
|
||||
{
|
||||
throw new Exception(_("noPerm","essentials.mail.send"));
|
||||
throw new Exception(_("noPerm", "essentials.mail.send"));
|
||||
}
|
||||
|
||||
Player player = server.getPlayer(args[1]);
|
||||
@ -59,7 +59,8 @@ public class Commandmail extends EssentialsCommand
|
||||
}
|
||||
if (!u.isIgnoredPlayer(user.getName()))
|
||||
{
|
||||
u.addMail(user.getName() + ": " + Util.stripColor(getFinalArg(args, 2)));
|
||||
final String mail = Util.sanitizeString(Util.stripColor(getFinalArg(args, 2)));
|
||||
u.addMail(user.getName() + ": " + mail);
|
||||
}
|
||||
user.sendMessage(_("mailSent"));
|
||||
return;
|
||||
@ -68,7 +69,7 @@ public class Commandmail extends EssentialsCommand
|
||||
{
|
||||
if (!user.isAuthorized("essentials.mail.sendall"))
|
||||
{
|
||||
throw new Exception(_("noPerm","essentials.mail.sendall"));
|
||||
throw new Exception(_("noPerm", "essentials.mail.sendall"));
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripColor(getFinalArg(args, 1))));
|
||||
user.sendMessage(_("mailSent"));
|
||||
|
@ -129,7 +129,7 @@ public class SignProtection extends EssentialsSign
|
||||
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
|
||||
{
|
||||
final BlockSign sign = new BlockSign(block);
|
||||
if (sign.getLine(0).equalsIgnoreCase(this.getSuccessName()))
|
||||
if (sign.getLine(0).equals(this.getSuccessName()))
|
||||
{
|
||||
return checkProtectionSign(sign, user, username);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user