fix: make sure a single name is not empty
authorINOPIAE <m.maengel@inopiae.de>
Tue, 24 Jul 2018 19:11:22 +0000 (21:11 +0200)
committerINOPIAE <m.maengel@inopiae.de>
Thu, 9 Aug 2018 15:25:11 +0000 (17:25 +0200)
Change-Id: Ic375db394c6fc7524e71dd026cd68e26999596a2

src/club/wpia/gigi/output/NameInput.java

index 11c8de5..d9116b1 100644 (file)
@@ -8,8 +8,8 @@ import javax.servlet.http.HttpServletRequest;
 import club.wpia.gigi.GigiApiException;
 import club.wpia.gigi.dbObjects.Name;
 import club.wpia.gigi.dbObjects.NamePart;
-import club.wpia.gigi.dbObjects.User;
 import club.wpia.gigi.dbObjects.NamePart.NamePartType;
+import club.wpia.gigi.dbObjects.User;
 import club.wpia.gigi.localisation.Language;
 import club.wpia.gigi.output.template.Outputable;
 import club.wpia.gigi.output.template.Template;
@@ -74,8 +74,11 @@ public class NameInput implements Outputable {
 
     public NamePart[] getNameParts() throws GigiApiException {
         if ("single".equals(scheme)) {
+            if (name == null || name.trim().isEmpty()) {
+                throw new GigiApiException("requires at least one character in the single name");
+            }
             return new NamePart[] {
-                    new NamePart(NamePartType.SINGLE_NAME, name)
+                    new NamePart(NamePartType.SINGLE_NAME, name.trim())
             };
         }
         String[] fparts = split(fname);