summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-07-17 09:46:50 (GMT)
committerSwift Review <review@swift.im>2014-08-10 11:08:27 (GMT)
commit8ec22a9c5591584fd1725ed028d714c51b7509d3 (patch)
tree3687e7023696c9e790a24fd54b7d04f14ac58ab2 /Swiften/IDN/UnitTest
parent5e9e715e49a5ddb6ce9c76ec61e7ecfd6eacdb58 (diff)
downloadswift-8ec22a9c5591584fd1725ed028d714c51b7509d3.zip
swift-8ec22a9c5591584fd1725ed028d714c51b7509d3.tar.bz2
Fix invalid characters being allowed in JID domains
Test-Information: Prepare valid and invalid JIDs and make sure that isValid() is reported correctly. Added unit tests. Change-Id: Ic4d86f8b6ea9defc517ada2f8e3cc54979237cf4
Diffstat (limited to 'Swiften/IDN/UnitTest')
-rw-r--r--Swiften/IDN/UnitTest/IDNConverterTest.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/Swiften/IDN/UnitTest/IDNConverterTest.cpp b/Swiften/IDN/UnitTest/IDNConverterTest.cpp
index 285cf4b..a66e141 100644
--- a/Swiften/IDN/UnitTest/IDNConverterTest.cpp
+++ b/Swiften/IDN/UnitTest/IDNConverterTest.cpp
@@ -19,6 +19,7 @@ class IDNConverterTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testStringPrep_Empty);
CPPUNIT_TEST(testGetEncoded);
CPPUNIT_TEST(testGetEncoded_International);
+ CPPUNIT_TEST(testGetEncoded_Invalid);
CPPUNIT_TEST_SUITE_END();
public:
@@ -39,15 +40,21 @@ class IDNConverterTest : public CppUnit::TestFixture {
}
void testGetEncoded() {
- std::string result = testling->getIDNAEncoded("www.swift.im");
- CPPUNIT_ASSERT_EQUAL(std::string("www.swift.im"), result);
+ boost::optional<std::string> result = testling->getIDNAEncoded("www.swift.im");
+ CPPUNIT_ASSERT(!!result);
+ CPPUNIT_ASSERT_EQUAL(std::string("www.swift.im"), *result);
}
void testGetEncoded_International() {
- std::string result = testling->getIDNAEncoded("www.tron\xc3\x87on.com");
- CPPUNIT_ASSERT_EQUAL(std::string("www.xn--tronon-zua.com"), result);
+ boost::optional<std::string> result = testling->getIDNAEncoded("www.tron\xc3\x87on.com");
+ CPPUNIT_ASSERT(!!result);
+ CPPUNIT_ASSERT_EQUAL(std::string("www.xn--tronon-zua.com"), *result);
}
+ void testGetEncoded_Invalid() {
+ boost::optional<std::string> result = testling->getIDNAEncoded("www.foo,bar.com");
+ CPPUNIT_ASSERT(!result);
+ }
private:
boost::shared_ptr<IDNConverter> testling;