From 7136ec8cee4e60c1923db8bf6ccb62c43d779497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be> Date: Sun, 22 May 2011 10:17:09 +0200 Subject: Fixed bug in JID escaping. diff --git a/Swiften/JID/JID.cpp b/Swiften/JID/JID.cpp index 7945cef..9fa0574 100644 --- a/Swiften/JID/JID.cpp +++ b/Swiften/JID/JID.cpp @@ -219,7 +219,7 @@ std::string JID::getEscapedNode(const std::string& node) { else if (*i == '\\') { // Check if we have an escaped dissalowed character sequence std::string::const_iterator innerBegin = i + 1; - if (innerBegin != result.end() && innerBegin + 1 != result.end()) { + if (innerBegin != node.end() && innerBegin + 1 != node.end()) { std::string::const_iterator innerEnd = innerBegin + 2; unsigned char value; if (getEscapeSequenceValue(std::string(innerBegin, innerEnd), value)) { diff --git a/Swiften/JID/UnitTest/JIDTest.cpp b/Swiften/JID/UnitTest/JIDTest.cpp index 6b5409f..6f7895a 100644 --- a/Swiften/JID/UnitTest/JIDTest.cpp +++ b/Swiften/JID/UnitTest/JIDTest.cpp @@ -53,6 +53,7 @@ class JIDTest : public CppUnit::TestFixture CPPUNIT_TEST(testHasResource_NoResource); CPPUNIT_TEST(testGetEscapedNode); CPPUNIT_TEST(testGetEscapedNode_XEP106Examples); + CPPUNIT_TEST(testGetEscapedNode_BackslashAtEnd); CPPUNIT_TEST(testGetUnescapedNode); CPPUNIT_TEST(testGetUnescapedNode_XEP106Examples); CPPUNIT_TEST_SUITE_END(); @@ -342,6 +343,10 @@ class JIDTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(JID::getEscapedNode("c:\\5commas"), std::string("c\\3a\\5c5commas")); } + void testGetEscapedNode_BackslashAtEnd() { + CPPUNIT_ASSERT_EQUAL(std::string("foo\\"), JID::getEscapedNode("foo\\")); + } + void testGetUnescapedNode() { std::string input = "\\& \" ' / <\\\\> @ : \\5c\\40"; JID testling(JID::getEscapedNode(input) + "@y"); -- cgit v0.10.2-6-g49f6