]> nmode's Git Repositories - signal-cli/commitdiff
Check if the username is a valid phone number with country code
authorAsamK <asamk@gmx.de>
Sun, 6 Dec 2015 16:22:39 +0000 (17:22 +0100)
committerAsamK <asamk@gmx.de>
Sun, 6 Dec 2015 16:22:39 +0000 (17:22 +0100)
src/main/java/cli/Main.java

index 8aedd95840cbb175db703f105135a412e3d49901..4353574967680b580b5eb601e6774cafe409da12 100644 (file)
@@ -27,6 +27,7 @@ import org.whispersystems.textsecure.api.push.exceptions.EncapsulatedExceptions;
 import org.whispersystems.textsecure.api.push.exceptions.NetworkFailureException;
 import org.whispersystems.textsecure.api.push.exceptions.UnregisteredUserException;
 import org.whispersystems.textsecure.api.util.InvalidNumberException;
+import org.whispersystems.textsecure.api.util.PhoneNumberFormatter;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -347,6 +348,10 @@ public class Main {
                 System.err.println("You need to specify a username (phone number)");
                 System.exit(2);
             }
+            if (!PhoneNumberFormatter.isValidNumber(ns.getString("username"))) {
+                System.err.println("Invalid username (phone number), make sure you include the country code.");
+                System.exit(2);
+            }
             if (ns.getList("recipient") != null && !ns.getList("recipient").isEmpty() && ns.getString("group") != null) {
                 System.err.println("You cannot specify recipients by phone number and groups a the same time");
                 System.exit(2);