From 5885bc7f252631a5f41ed8dd4c8d354dbfeb922c Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 5 Dec 2017 17:29:05 +0100 Subject: [PATCH] show warning when opening invalid jid --- .../conversations/ui/StartConversationActivity.java | 4 ++++ src/main/java/eu/siacs/conversations/utils/XmppUri.java | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 765e77bcb..b24613079 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -1193,6 +1193,10 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU public String account; boolean invite() { + if (!isJidValid()) { + Toast.makeText(StartConversationActivity.this,R.string.invalid_jid,Toast.LENGTH_SHORT).show(); + return false; + } if (getJid() != null) { return handleJid(this); } diff --git a/src/main/java/eu/siacs/conversations/utils/XmppUri.java b/src/main/java/eu/siacs/conversations/utils/XmppUri.java index 9e8f6111c..bfd4b7c65 100644 --- a/src/main/java/eu/siacs/conversations/utils/XmppUri.java +++ b/src/main/java/eu/siacs/conversations/utils/XmppUri.java @@ -151,6 +151,15 @@ public class XmppUri { } } + public boolean isJidValid() { + try { + Jid.fromString(jid); + return true; + } catch (InvalidJidException e) { + return false; + } + } + public String getBody() { return body; }