From 508a5e258d5de152b5b58ceca67a0135383f4fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Wed, 25 Apr 2012 20:40:18 +0200 Subject: Don't linkify /me actions. Resolves: #959 diff --git a/SwifTools/Linkify.cpp b/SwifTools/Linkify.cpp index 2ca284d..906026d 100644 --- a/SwifTools/Linkify.cpp +++ b/SwifTools/Linkify.cpp @@ -21,7 +21,7 @@ std::string Linkify::linkify(const std::string& input) { for (size_t i = 0; i < input.size(); ++i) { char c = input[i]; if (inURL) { - if (c != ' ' && c != '\t' && c != '\n') { + if (c != ' ' && c != '\t' && c != '\n' && !(c == '*' && i == input.size() - 1 && input[0] == '*')) { currentURL.push_back(c); } else { diff --git a/SwifTools/UnitTest/LinkifyTest.cpp b/SwifTools/UnitTest/LinkifyTest.cpp index 3d0ce00..5df1a96 100644 --- a/SwifTools/UnitTest/LinkifyTest.cpp +++ b/SwifTools/UnitTest/LinkifyTest.cpp @@ -31,6 +31,7 @@ class LinkifyTest : public CppUnit::TestFixture { CPPUNIT_TEST(testLinkify_UnicodeCharacter); CPPUNIT_TEST(testLinkify_NewLine); CPPUNIT_TEST(testLinkify_Tab); + CPPUNIT_TEST(testLinkify_Action); CPPUNIT_TEST_SUITE_END(); public: @@ -178,6 +179,14 @@ class LinkifyTest : public CppUnit::TestFixture { std::string("http://swift.im\tfoo"), result); } + + void testLinkify_Action() { + std::string result = Linkify::linkify("*http://swift.im*"); + + CPPUNIT_ASSERT_EQUAL( + std::string("*http://swift.im*"), + result); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(LinkifyTest); -- cgit v0.10.2-6-g49f6