size limit on nicknames
This commit is contained in:
@ -5,6 +5,7 @@ import net.i2p.crypto.SigType;
|
||||
public class Constants {
|
||||
public static final byte PERSONA_VERSION = (byte)1;
|
||||
public static final String INVALID_NICKNAME_CHARS = "'\"();<>=@$%";
|
||||
public static final int MAX_NICKNAME_LENGTH = 30;
|
||||
public static final byte FILE_CERT_VERSION = (byte)2;
|
||||
public static final int CHAT_VERSION = 1;
|
||||
|
||||
|
@ -218,6 +218,8 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
public static boolean isValidName(String name) {
|
||||
if (name.length() > Constants.MAX_NICKNAME_LENGTH)
|
||||
return false;
|
||||
for (int i = 0; i < Constants.INVALID_NICKNAME_CHARS.length(); i++)
|
||||
if (name.indexOf(Constants.INVALID_NICKNAME_CHARS.charAt(i)) >= 0)
|
||||
return false;
|
||||
|
@ -119,7 +119,8 @@ class Ready extends AbstractLifecycleHandler {
|
||||
continue
|
||||
}
|
||||
if (!DataUtil.isValidName(nickname)) {
|
||||
JOptionPane.showMessageDialog(null, "Nickname cannot contain any of ${Constants.INVALID_NICKNAME_CHARS} choose another",
|
||||
JOptionPane.showMessageDialog(null,
|
||||
"Nickname cannot contain any of ${Constants.INVALID_NICKNAME_CHARS} and must be no longer than ${Constants.MAX_NICKNAME_LENGTH} characters. Choose another.",
|
||||
"Select another nickname", JOptionPane.WARNING_MESSAGE)
|
||||
continue
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ public class InitServlet extends HttpServlet {
|
||||
throw new Exception("Nickname cannot be blank");
|
||||
|
||||
if (!DataUtil.isValidName(nickname))
|
||||
throw new Exception("Nickname cannot contain any of " + Constants.INVALID_NICKNAME_CHARS);
|
||||
throw new Exception("Nickname cannot contain any of " + Constants.INVALID_NICKNAME_CHARS +
|
||||
" and must be no longer than " + Constants.MAX_NICKNAME_LENGTH + " characters.");
|
||||
|
||||
String downloadLocation = req.getParameter("download_location");
|
||||
if (downloadLocation == null)
|
||||
|
Reference in New Issue
Block a user