From a25333888df96bdc33bbf68bfe21515c1cb2b358 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Mon, 21 May 2007 16:01:12 +0000 Subject: Fixed bug #1656547: segfault in urlUtils::decode() if the string ends with '%'. --- tests/utility/urlTest.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests/utility/urlTest.cpp') diff --git a/tests/utility/urlTest.cpp b/tests/utility/urlTest.cpp index f9bb4dae..2630a99e 100644 --- a/tests/utility/urlTest.cpp +++ b/tests/utility/urlTest.cpp @@ -42,6 +42,7 @@ VMIME_TEST_SUITE_BEGIN VMIME_TEST(testGenerate) VMIME_TEST(testUtilsEncode) VMIME_TEST(testUtilsDecode) + VMIME_TEST(testUtilsDecodeSpecialCases) VMIME_TEST(testUtilsEncodeReservedChars) VMIME_TEST(testUtilsEncodeUnsafeChars) VMIME_TEST_LIST_END @@ -239,7 +240,7 @@ VMIME_TEST_SUITE_BEGIN { std::ostringstream ossTest; ossTest << "%" << "0123456789ABCDEF"[i / 16] - << "0123456789ABCDEF"[i % 16]; + << "0123456789ABCDEF"[i % 16]; std::ostringstream ossNum; ossNum << i; @@ -253,6 +254,14 @@ VMIME_TEST_SUITE_BEGIN } + void testUtilsDecodeSpecialCases() + { + // Bug #1656547: segfault with '%' at the end of the string + VASSERT_EQ("1.1", "sadfsda%", vmime::utility::urlUtils::decode("sadfsda%")); + VASSERT_EQ("1.2", "sadfsda\x05", vmime::utility::urlUtils::decode("sadfsda%5")); + VASSERT_EQ("1.3", "sadfsda\x42", vmime::utility::urlUtils::decode("sadfsda%42")); + } + void testUtilsEncodeReservedChars() { VASSERT_EQ("1", "%24", vmime::utility::urlUtils::encode("$")); -- cgit v1.2.3