mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 20:29:20 +00:00
Sanitize mail for untoward characters.
Prevent a user error from terminating essentials timer task.
This commit is contained in:
parent
92fa415848
commit
5c19e71858
4 changed files with 25 additions and 10 deletions
|
@ -3,6 +3,7 @@ package com.earth2me.essentials;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.logging.Level;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,12 +22,19 @@ public class EssentialsTimer implements Runnable
|
||||||
{
|
{
|
||||||
final long currentTime = System.currentTimeMillis();
|
final long currentTime = System.currentTimeMillis();
|
||||||
for (Player player : ess.getServer().getOnlinePlayers())
|
for (Player player : ess.getServer().getOnlinePlayers())
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
final User user = ess.getUser(player);
|
final User user = ess.getUser(player);
|
||||||
onlineUsers.add(user);
|
onlineUsers.add(user);
|
||||||
user.setLastOnlineActivity(currentTime);
|
user.setLastOnlineActivity(currentTime);
|
||||||
user.checkActivity();
|
user.checkActivity();
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
ess.getLogger().log(Level.WARNING, "EssentialsTimer Error:", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Iterator<User> iterator = onlineUsers.iterator();
|
final Iterator<User> iterator = onlineUsers.iterator();
|
||||||
while (iterator.hasNext())
|
while (iterator.hasNext())
|
||||||
|
|
|
@ -21,11 +21,17 @@ public class Util
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
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)
|
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)
|
public static String formatDateDiff(long date)
|
||||||
|
|
|
@ -59,7 +59,8 @@ public class Commandmail extends EssentialsCommand
|
||||||
}
|
}
|
||||||
if (!u.isIgnoredPlayer(user.getName()))
|
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"));
|
user.sendMessage(_("mailSent"));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class SignProtection extends EssentialsSign
|
||||||
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
|
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
|
||||||
{
|
{
|
||||||
final BlockSign sign = new BlockSign(block);
|
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);
|
return checkProtectionSign(sign, user, username);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue