diff options
author | Daniel Gultsch <inputmice@siacs.eu> | 2015-01-05 15:08:13 +0100 |
---|---|---|
committer | Daniel Gultsch <inputmice@siacs.eu> | 2015-01-05 15:08:13 +0100 |
commit | 2679824770b025e65a9a848c1112219bc8df1b37 (patch) | |
tree | 829deded9a4d270538bff2411ab5523a84543b8f /src/main/java/eu | |
parent | bdb335e6b08d35a23468ca1d5730330c520a6a90 (diff) |
prevent QR code parser from crashing fixed #839
Diffstat (limited to 'src/main/java/eu')
-rw-r--r-- | src/main/java/eu/siacs/conversations/utils/XmppUri.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/main/java/eu/siacs/conversations/utils/XmppUri.java b/src/main/java/eu/siacs/conversations/utils/XmppUri.java index aacb6362f..0f1b18c39 100644 --- a/src/main/java/eu/siacs/conversations/utils/XmppUri.java +++ b/src/main/java/eu/siacs/conversations/utils/XmppUri.java @@ -18,7 +18,11 @@ public class XmppUri { try { parse(Uri.parse(uri)); } catch (IllegalArgumentException e) { - jid = null; + try { + jid = Jid.fromString(uri).toBareJid().toString(); + } catch (InvalidJidException e2) { + jid = null; + } } } @@ -42,6 +46,13 @@ public class XmppUri { try { jid = URLDecoder.decode(uri.getEncodedPath(), "UTF-8").split("/")[1]; } catch (final UnsupportedEncodingException ignored) { + jid = null; + } + } else { + try { + jid = Jid.fromString(uri.toString()).toBareJid().toString(); + } catch (final InvalidJidException ignored) { + jid = null; } } } @@ -62,7 +73,7 @@ public class XmppUri { public Jid getJid() { try { - return Jid.fromString(this.jid); + return this.jid == null ? null :Jid.fromString(this.jid); } catch (InvalidJidException e) { return null; } @@ -71,8 +82,4 @@ public class XmppUri { public String getFingerprint() { return this.fingerprint; } - - public boolean isMuc() { - return this.muc; - } } |