From 9c7828d943bede78dbc9e52c22880cd06b65a8ba Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
Date: Wed, 8 Sep 2010 10:16:07 -0400
Subject: [PATCH] [#3963] Fix instant message parsing (text/plain &
 recipient-list)

---
 sflphone-common/src/sip/im/InstantMessaging.cpp | 4 ++--
 sflphone-common/test/instantmessagingtest.cpp   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sflphone-common/src/sip/im/InstantMessaging.cpp b/sflphone-common/src/sip/im/InstantMessaging.cpp
index 572e0e0510..1c3cecdeea 100644
--- a/sflphone-common/src/sip/im/InstantMessaging.cpp
+++ b/sflphone-common/src/sip/im/InstantMessaging.cpp
@@ -314,7 +314,7 @@ std::string InstantMessaging::findTextUriList (std::string& text)
 
     size_t end = text.find (boundary, begin);
 
-    return text.substr (begin+2, end-begin);
+    return text.substr (begin+2, end-begin-2);
 }
 
 std::string InstantMessaging::findTextMessage (std::string& text)
@@ -328,7 +328,7 @@ std::string InstantMessaging::findTextMessage (std::string& text)
 
     size_t end = text.find (boundary, begin);
 
-    return text.substr (begin+2, end-begin);
+    return text.substr (begin+2, end-begin-3);
 }
 
 
diff --git a/sflphone-common/test/instantmessagingtest.cpp b/sflphone-common/test/instantmessagingtest.cpp
index d5a96f955c..d14bc773a9 100644
--- a/sflphone-common/test/instantmessagingtest.cpp
+++ b/sflphone-common/test/instantmessagingtest.cpp
@@ -284,7 +284,7 @@ void InstantMessagingTest::testGetTextArea ()
 
     std::string message = _im->findTextMessage(formatedText);
 
-    // CPPUNIT_ASSERT(message == "Here is the text area");
+    CPPUNIT_ASSERT(message == "Here is the text area");
 
     std::cout << "message: " << message << std::endl;
 }
@@ -308,7 +308,7 @@ void InstantMessagingTest::testGetUriListArea ()
 
     std::string urilist = _im->findTextUriList(formatedText);
 
-    // CPPUNIT_ASSERT(urilist.compare("<?xml version=\"1.0\" encoding=\"UTF-8\"?><resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:cp=\"urn:ietf:params:xml:ns:copycontrol\"><list><entry uri=\"sip:alex@example.com\" cp:copyControl=\"to\" /><entry uri=\"sip:manu@example.com\" cp:copyControl=\"to\" /></list></resource-lists>") == 0);
+    CPPUNIT_ASSERT(urilist.compare("<?xml version=\"1.0\" encoding=\"UTF-8\"?><resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:cp=\"urn:ietf:params:xml:ns:copycontrol\"><list><entry uri=\"sip:alex@example.com\" cp:copyControl=\"to\" /><entry uri=\"sip:manu@example.com\" cp:copyControl=\"to\" /></list></resource-lists>") == 0);
 
     std::cout << "urilist: " << urilist << std::endl;
 }
-- 
GitLab