diff --git a/src/utility/url.cpp b/src/utility/url.cpp index 980922d0..2842b524 100644 --- a/src/utility/url.cpp +++ b/src/utility/url.cpp @@ -165,7 +165,7 @@ void url::parse(const string& str) string::size_type slashPos = str.find('/', protoEnd + 3); if (slashPos == string::npos) slashPos = str.length(); - string::size_type atPos = str.find('@', protoEnd + 3); + string::size_type atPos = str.rfind('@', slashPos); string hostPart; string username; diff --git a/tests/utility/urlTest.cpp b/tests/utility/urlTest.cpp index d023476a..9214eb1c 100644 --- a/tests/utility/urlTest.cpp +++ b/tests/utility/urlTest.cpp @@ -38,6 +38,7 @@ VMIME_TEST_SUITE_BEGIN VMIME_TEST(testParse2) VMIME_TEST(testParse3) VMIME_TEST(testParse4) + VMIME_TEST(testParse5) VMIME_TEST(testGenerate) VMIME_TEST(testUtilsEncode) VMIME_TEST(testUtilsDecode) @@ -190,6 +191,17 @@ VMIME_TEST_SUITE_BEGIN VASSERT_EQ("4.4", "/path", u4.getPath()); } + // '@' symbol in the username part + void testParse5() + { + vmime::utility::url u1("", ""); + + VASSERT_EQ("1", true, parseHelper(u1, "imap://account@myserver.com:password@myserver.com")); + VASSERT_EQ("2", "account@myserver.com", u1.getUsername()); + VASSERT_EQ("3", "password", u1.getPassword()); + VASSERT_EQ("4", "myserver.com", u1.getHost()); + } + void testGenerate() { vmime::utility::url u1("proto", "host", 12345, "path", "user", "password");