From 7f1b958ef2f9d1b892c51d5f7de3a6ab5669a804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sun, 26 Dec 2010 20:13:42 +0100 Subject: Fixed linkifying of unicode URLs. diff --git a/SwifTools/Linkify.cpp b/SwifTools/Linkify.cpp index 0dfa7b5..32428ec 100644 --- a/SwifTools/Linkify.cpp +++ b/SwifTools/Linkify.cpp @@ -21,7 +21,7 @@ String Linkify::linkify(const String& input) { for (size_t i = 0; i < input.getUTF8Size(); ++i) { char c = input[i]; if (inURL) { - if (c >= 33 && c != '\\' && c != '"') { + if (c != ' ' && c != '\t') { currentURL.push_back(c); } else { diff --git a/SwifTools/UnitTest/LinkifyTest.cpp b/SwifTools/UnitTest/LinkifyTest.cpp index 9655b87..60edc9b 100644 --- a/SwifTools/UnitTest/LinkifyTest.cpp +++ b/SwifTools/UnitTest/LinkifyTest.cpp @@ -28,6 +28,7 @@ class LinkifyTest : public CppUnit::TestFixture { CPPUNIT_TEST(testLinkify_Authentication); CPPUNIT_TEST(testLinkify_At); CPPUNIT_TEST(testLinkify_Amps); + CPPUNIT_TEST(testLinkify_UnicodeCharacter); CPPUNIT_TEST_SUITE_END(); public: @@ -151,6 +152,14 @@ class LinkifyTest : public CppUnit::TestFixture { String("http://swift.im/foo&bar&baz"), result); } + + void testLinkify_UnicodeCharacter() { + String result = Linkify::linkify("http://\xe2\x98\x83.net"); + + CPPUNIT_ASSERT_EQUAL( + String("http://\xe2\x98\x83.net"), + result); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(LinkifyTest); -- cgit v0.10.2-6-g49f6