forward port IPv6 IP address resolution in URLs fix

This commit is contained in:
arvidn 2015-11-01 17:26:45 -05:00
parent ce33f23eab
commit ee714306be
3 changed files with 7 additions and 7 deletions

View File

@ -78,6 +78,7 @@
1.0.7 release 1.0.7 release
* fix IPv6 IP address resolution in URLs
* introduce run-time check for torrent info-sections beeing too large * introduce run-time check for torrent info-sections beeing too large
* fix web seed bug when using proxy and proxy-peer-connections=false * fix web seed bug when using proxy and proxy-peer-connections=false
* fix bug in magnet link parser * fix bug in magnet link parser

View File

@ -101,16 +101,19 @@ namespace libtorrent
ec = errors::expected_close_bracket_in_address; ec = errors::expected_close_bracket_in_address;
goto exit; goto exit;
} }
// strip the brackets
hostname.assign(start + 1, port_pos);
port_pos = std::find(port_pos, url.end(), ':'); port_pos = std::find(port_pos, url.end(), ':');
} }
else else
{ {
port_pos = std::find(start, url.end(), ':'); port_pos = std::find(start, url.end(), ':');
if (port_pos < end) hostname.assign(start, port_pos);
else hostname.assign(start, end);
} }
if (port_pos < end) if (port_pos < end)
{ {
hostname.assign(start, port_pos);
++port_pos; ++port_pos;
for (std::string::iterator i = port_pos; i < end; ++i) for (std::string::iterator i = port_pos; i < end; ++i)
{ {
@ -120,10 +123,6 @@ namespace libtorrent
} }
port = std::atoi(std::string(port_pos, end).c_str()); port = std::atoi(std::string(port_pos, end).c_str());
} }
else
{
hostname.assign(start, end);
}
start = end; start = end;
exit: exit:

View File

@ -403,11 +403,11 @@ TORRENT_TEST(http_parser)
== make_tuple("http", "", "192.168.0.1", -1, "/path/to/file")); == make_tuple("http", "", "192.168.0.1", -1, "/path/to/file"));
TEST_CHECK(parse_url_components("http://[2001:ff00::1]:42/path/to/file", ec) TEST_CHECK(parse_url_components("http://[2001:ff00::1]:42/path/to/file", ec)
== make_tuple("http", "", "[2001:ff00::1]", 42, "/path/to/file")); == make_tuple("http", "", "2001:ff00::1", 42, "/path/to/file"));
// leading spaces are supposed to be stripped // leading spaces are supposed to be stripped
TEST_CHECK(parse_url_components(" \thttp://[2001:ff00::1]:42/path/to/file", ec) TEST_CHECK(parse_url_components(" \thttp://[2001:ff00::1]:42/path/to/file", ec)
== make_tuple("http", "", "[2001:ff00::1]", 42, "/path/to/file")); == make_tuple("http", "", "2001:ff00::1", 42, "/path/to/file"));
parse_url_components("http://[2001:ff00::1:42/path/to/file", ec); parse_url_components("http://[2001:ff00::1:42/path/to/file", ec);
TEST_CHECK(ec == error_code(errors::expected_close_bracket_in_address)); TEST_CHECK(ec == error_code(errors::expected_close_bracket_in_address));