merged fix from RC_0_16
This commit is contained in:
parent
af6dbc5d79
commit
c94ed806db
|
@ -25,6 +25,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 issue when loading certain malformed .torrent files
|
||||||
* pass along host header with http proxy requests and possible http_connection shutdown hang
|
* pass along host header with http proxy requests and possible http_connection shutdown hang
|
||||||
|
|
||||||
0.16.12 release
|
0.16.12 release
|
||||||
|
|
29
src/file.cpp
29
src/file.cpp
|
@ -409,16 +409,33 @@ namespace libtorrent
|
||||||
|
|
||||||
std::string extension(std::string const& f)
|
std::string extension(std::string const& f)
|
||||||
{
|
{
|
||||||
char const* ext = strrchr(f.c_str(), '.');
|
for (int i = f.size() - 1; i >= 0; --i)
|
||||||
if (ext == 0) return "";
|
{
|
||||||
return ext;
|
if (f[i] == '/') break;
|
||||||
|
#ifdef TORRENT_WINDOWS
|
||||||
|
if (f[i] == '\\') break;
|
||||||
|
#endif
|
||||||
|
if (f[i] != '.') continue;
|
||||||
|
return f.substr(i);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void replace_extension(std::string& f, std::string const& ext)
|
void replace_extension(std::string& f, std::string const& ext)
|
||||||
{
|
{
|
||||||
char const* e = strrchr(f.c_str(), '.');
|
for (int i = f.size() - 1; i >= 0; --i)
|
||||||
if (e == 0) f += '.';
|
{
|
||||||
else f.resize(e - f.c_str() + 1);
|
if (f[i] == '/') break;
|
||||||
|
#ifdef TORRENT_WINDOWS
|
||||||
|
if (f[i] == '\\') break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (f[i] != '.') continue;
|
||||||
|
|
||||||
|
f.resize(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
f += '.';
|
||||||
f += ext;
|
f += ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,6 +308,8 @@ namespace libtorrent
|
||||||
if (p->list_at(i)->type() != lazy_entry::string_t)
|
if (p->list_at(i)->type() != lazy_entry::string_t)
|
||||||
return false;
|
return false;
|
||||||
std::string path_element = p->list_at(i)->string_value();
|
std::string path_element = p->list_at(i)->string_value();
|
||||||
|
if (path_element.empty())
|
||||||
|
path_element = "_";
|
||||||
if (!valid_path_element(path_element)) continue;
|
if (!valid_path_element(path_element)) continue;
|
||||||
if (i == end - 1) *filename = p->list_at(i);
|
if (i == end - 1) *filename = p->list_at(i);
|
||||||
trim_path_element(path_element);
|
trim_path_element(path_element);
|
||||||
|
|
|
@ -125,6 +125,7 @@ int test_main()
|
||||||
TEST_EQUAL(extension("blah.exe"), ".exe");
|
TEST_EQUAL(extension("blah.exe"), ".exe");
|
||||||
TEST_EQUAL(extension("blah.foo.bar"), ".bar");
|
TEST_EQUAL(extension("blah.foo.bar"), ".bar");
|
||||||
TEST_EQUAL(extension("blah.foo."), ".");
|
TEST_EQUAL(extension("blah.foo."), ".");
|
||||||
|
TEST_EQUAL(extension("blah.foo/bar"), "");
|
||||||
|
|
||||||
TEST_EQUAL(filename("blah"), "blah");
|
TEST_EQUAL(filename("blah"), "blah");
|
||||||
TEST_EQUAL(filename("/blah/foo/bar"), "bar");
|
TEST_EQUAL(filename("/blah/foo/bar"), "bar");
|
||||||
|
@ -209,6 +210,15 @@ int test_main()
|
||||||
replace_extension(test, "txt");
|
replace_extension(test, "txt");
|
||||||
TEST_EQUAL(test, "foo.txt");
|
TEST_EQUAL(test, "foo.txt");
|
||||||
|
|
||||||
|
test = "_";
|
||||||
|
replace_extension(test, "txt");
|
||||||
|
TEST_EQUAL(test, "_.txt");
|
||||||
|
|
||||||
|
test = "1.2.3/_";
|
||||||
|
replace_extension(test, "txt");
|
||||||
|
TEST_EQUAL(test, "1.2.3/_.txt");
|
||||||
|
|
||||||
|
|
||||||
// file class
|
// file class
|
||||||
file f;
|
file f;
|
||||||
#if TORRENT_USE_UNC_PATHS || !defined WIN32
|
#if TORRENT_USE_UNC_PATHS || !defined WIN32
|
||||||
|
|
|
@ -71,6 +71,7 @@ test_torrent_t test_torrents[] =
|
||||||
{ "url_seed_multi_space.torrent" },
|
{ "url_seed_multi_space.torrent" },
|
||||||
{ "url_seed_multi_space_nolist.torrent" },
|
{ "url_seed_multi_space_nolist.torrent" },
|
||||||
{ "root_hash.torrent" },
|
{ "root_hash.torrent" },
|
||||||
|
{ "empty_path_multi.torrent" },
|
||||||
};
|
};
|
||||||
|
|
||||||
struct test_failing_torrent_t
|
struct test_failing_torrent_t
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
d10:created by10:libtorrent13:creation datei1359599503e4:infod5:filesld6:lengthi425e4:pathl5:abcdeeed6:lengthi3e4:pathl0:eed6:lengthi5e4:pathl0:eee4:name4:temp12:piece lengthi16384e6:pieces20:‚ž¼Œ&¾ÇJW›}ÜA4u,·¼‘‡ee
|
Loading…
Reference in New Issue