merged url escaping fix from RC_0_16

This commit is contained in:
Arvid Norberg 2013-08-16 16:38:09 +00:00
parent 3258d92f64
commit 5141a6505a
3 changed files with 12 additions and 5 deletions

View File

@ -23,6 +23,7 @@
* fix uTP edge case where udp socket buffer fills up * fix uTP edge case where udp socket buffer fills up
* fix nagle implementation in uTP * fix nagle implementation in uTP
* fix web seed URL double escape issue
* fix string encoding issue in alert messages * fix string encoding issue in alert messages
* fix SSL authentication issue * fix SSL authentication issue
* deprecate std::wstring overloads. long live utf-8 * deprecate std::wstring overloads. long live utf-8

View File

@ -234,6 +234,8 @@ namespace libtorrent
request += "GET "; request += "GET ";
if (using_proxy) if (using_proxy)
{ {
// m_url is already a properly escaped URL
// with the correct slashes. Don't encode it again
request += m_url; request += m_url;
std::string path = info.orig_files().file_path(f.file_index); std::string path = info.orig_files().file_path(f.file_index);
#ifdef TORRENT_WINDOWS #ifdef TORRENT_WINDOWS
@ -243,8 +245,11 @@ namespace libtorrent
} }
else else
{ {
std::string path = m_path; // m_path is already a properly escaped URL
path += info.orig_files().file_path(f.file_index); // 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 #ifdef TORRENT_WINDOWS
convert_path_to_posix(path); convert_path_to_posix(path);
#endif #endif

View File

@ -1260,9 +1260,10 @@ int test_main()
TEST_CHECK(need_encoding("\n", 1) == true); TEST_CHECK(need_encoding("\n", 1) == true);
// maybe_url_encode // maybe_url_encode
TEST_CHECK(maybe_url_encode("http://bla.com/\n") == "http://bla.com/%0a"); TEST_EQUAL(maybe_url_encode("http://bla.com/\n"), "http://bla.com/%0a");
std::cerr << maybe_url_encode("http://bla.com/\n") << std::endl; TEST_EQUAL(maybe_url_encode("http://bla.com/foo%20bar"), "http://bla.com/foo%20bar");
TEST_CHECK(maybe_url_encode("?&") == "?&"); 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 // unescape_string
TEST_CHECK(unescape_string(escape_string(test_string, strlen(test_string)), ec) TEST_CHECK(unescape_string(escape_string(test_string, strlen(test_string)), ec)