url: repair off-by-one bug in extractHost (#297)
`hostPart[len]` is pointing to `]`, but we need to check the char after that. Fixes: v0.9.2-187-g874a1d8c
This commit is contained in:
parent
c3c6242ed1
commit
c6b01fcc32
@ -180,7 +180,7 @@ static bool extractHostIPv6(string& hostPart, string& host, string& port) {
|
|||||||
|
|
||||||
host.assign(&hostPart[1], len - 1);
|
host.assign(&hostPart[1], len - 1);
|
||||||
|
|
||||||
if (hostPart[len] == '\0') {
|
if (hostPart[len + 1] == '\0') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (hostPart[len + 1] != ':') {
|
if (hostPart[len + 1] != ':') {
|
||||||
|
@ -35,7 +35,8 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
|
|||||||
VMIME_TEST(testParse3)
|
VMIME_TEST(testParse3)
|
||||||
VMIME_TEST(testParse4)
|
VMIME_TEST(testParse4)
|
||||||
VMIME_TEST(testParse5)
|
VMIME_TEST(testParse5)
|
||||||
VMIME_TEST(testParseIPv6)
|
VMIME_TEST(testParseIPv6Full)
|
||||||
|
VMIME_TEST(testParseIPv6NoPort)
|
||||||
VMIME_TEST(testGenerate)
|
VMIME_TEST(testGenerate)
|
||||||
VMIME_TEST(testUtilsEncode)
|
VMIME_TEST(testUtilsEncode)
|
||||||
VMIME_TEST(testUtilsDecode)
|
VMIME_TEST(testUtilsDecode)
|
||||||
@ -202,7 +203,7 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
|
|||||||
VASSERT_EQ("4", "myserver.com", u1.getHost());
|
VASSERT_EQ("4", "myserver.com", u1.getHost());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testParseIPv6() {
|
void testParseIPv6Full() {
|
||||||
|
|
||||||
vmime::utility::url u1("", "");
|
vmime::utility::url u1("", "");
|
||||||
|
|
||||||
@ -214,6 +215,14 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
|
|||||||
VASSERT_EQ("6", "/p", u1.getPath());
|
VASSERT_EQ("6", "/p", u1.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testParseIPv6NoPort() {
|
||||||
|
|
||||||
|
vmime::utility::url u1("", "");
|
||||||
|
|
||||||
|
VASSERT_EQ("1", true, parseHelper(u1, "http://[::1]/"));
|
||||||
|
VASSERT_EQ("2", "::1", u1.getHost());
|
||||||
|
}
|
||||||
|
|
||||||
void testGenerate() {
|
void testGenerate() {
|
||||||
|
|
||||||
vmime::utility::url u1("proto", "host", 12345, "path", "user", "password");
|
vmime::utility::url u1("proto", "host", 12345, "path", "user", "password");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user