disallow certain characters in nicknames

pull/53/head
Zlatin Balevsky 2020-05-06 11:49:52 +01:00
parent d18cdb15cd
commit 58a92e7442
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 6 additions and 0 deletions

View File

@ -8,6 +8,9 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.muwire.core.Constants;
import com.muwire.core.util.DataUtil;
public class InitServlet extends HttpServlet { public class InitServlet extends HttpServlet {
@Override @Override
@ -17,6 +20,9 @@ public class InitServlet extends HttpServlet {
if (nickname == null || nickname.trim().length() == 0) if (nickname == null || nickname.trim().length() == 0)
throw new Exception("Nickname cannot be blank"); throw new Exception("Nickname cannot be blank");
if (!DataUtil.isValidName(nickname))
throw new Exception("Nickname cannot contain any of " + Constants.INVALID_NICKNAME_CHARS);
String downloadLocation = req.getParameter("download_location"); String downloadLocation = req.getParameter("download_location");
if (downloadLocation == null) if (downloadLocation == null)
throw new Exception("Download location cannot be blank"); throw new Exception("Download location cannot be blank");