diff --git a/ChangeLog b/ChangeLog index a5d519ff3..836337398 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ * fix uTP edge case where udp socket buffer fills up * fix nagle implementation in uTP + * fix web seed URL double escape issue * fix string encoding issue in alert messages * fix SSL authentication issue * deprecate std::wstring overloads. long live utf-8 diff --git a/src/web_peer_connection.cpp b/src/web_peer_connection.cpp index 2b176fb89..8a1c9add0 100644 --- a/src/web_peer_connection.cpp +++ b/src/web_peer_connection.cpp @@ -234,6 +234,8 @@ namespace libtorrent request += "GET "; if (using_proxy) { + // m_url is already a properly escaped URL + // with the correct slashes. Don't encode it again request += m_url; std::string path = info.orig_files().file_path(f.file_index); #ifdef TORRENT_WINDOWS @@ -243,8 +245,11 @@ namespace libtorrent } else { - std::string path = m_path; - path += info.orig_files().file_path(f.file_index); + // m_path is already a properly escaped URL + // with the correct slashes. Don't encode it again + request += m_path; + + std::string path = info.orig_files().file_path(f.file_index); #ifdef TORRENT_WINDOWS convert_path_to_posix(path); #endif diff --git a/test/test_primitives.cpp b/test/test_primitives.cpp index 9d184e4ef..821abe891 100644 --- a/test/test_primitives.cpp +++ b/test/test_primitives.cpp @@ -1260,9 +1260,10 @@ int test_main() TEST_CHECK(need_encoding("\n", 1) == true); // maybe_url_encode - TEST_CHECK(maybe_url_encode("http://bla.com/\n") == "http://bla.com/%0a"); - std::cerr << maybe_url_encode("http://bla.com/\n") << std::endl; - TEST_CHECK(maybe_url_encode("?&") == "?&"); + TEST_EQUAL(maybe_url_encode("http://bla.com/\n"), "http://bla.com/%0a"); + TEST_EQUAL(maybe_url_encode("http://bla.com/foo%20bar"), "http://bla.com/foo%20bar"); + TEST_EQUAL(maybe_url_encode("http://bla.com/foo%20bar?k=v&k2=v2"), "http://bla.com/foo%20bar?k=v&k2=v2"); + TEST_EQUAL(maybe_url_encode("?&"), "?&"); // unescape_string TEST_CHECK(unescape_string(escape_string(test_string, strlen(test_string)), ec)