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 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

View File

@ -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

View File

@ -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)