From 83219052c32a2073f52aae8e4b1c15822343f04f Mon Sep 17 00:00:00 2001
From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Date: Thu, 14 Nov 2013 15:59:05 +0100
Subject: Fix JID parsing

---
 src/xmpp/jid.cpp | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

(limited to 'src/xmpp')

diff --git a/src/xmpp/jid.cpp b/src/xmpp/jid.cpp
index 78b28a0..29a5302 100644
--- a/src/xmpp/jid.cpp
+++ b/src/xmpp/jid.cpp
@@ -2,18 +2,20 @@
 
 Jid::Jid(const std::string& jid)
 {
-  std::string::size_type at = jid.find("@");
-  if (at != std::string::npos)
+  std::string::size_type slash = jid.find('/');
+  if (slash != std::string::npos)
+    {
+      this->resource = jid.substr(slash + 1);
+    }
+
+  std::string::size_type at = jid.find('@');
+  if (at != std::string::npos && at < slash)
     {
       this->local = jid.substr(0, at);
       at++;
     }
   else
     at = 0;
-  std::string::size_type slash = jid.find("/", at);
-  if (slash != std::string::npos)
-    {
-      this->resource = jid.substr(slash + 1);
-    }
+
   this->domain = jid.substr(at, slash - at);
 }
-- 
cgit v1.2.3