restore path sanitization behavior of ':'

This commit is contained in:
arvidn 2017-11-21 01:05:50 +01:00 committed by Arvid Norberg
parent 096ce54fae
commit 04c2c35f8d
3 changed files with 16 additions and 8 deletions

View File

@ -1,4 +1,5 @@
* restore path sanitization behavior of ":"
* fix listen socket issue when disabling "force_proxy" mode
* fix full allocation failure on APFS

View File

@ -103,11 +103,7 @@ namespace libtorrent
static const boost::array<boost::int32_t, 7> bad_cp = {{0x202a, 0x202b, 0x202c, 0x202d, 0x202e, 0x200e, 0x200f}};
if (std::find(bad_cp.begin(), bad_cp.end(), c) != bad_cp.end()) return true;
#ifdef TORRENT_WINDOWS
static const char invalid_chars[] = "/\\:";
#else
static const char invalid_chars[] = "/\\";
#endif
if (c > 127) return false;
return std::strchr(invalid_chars, static_cast<char>(c)) != NULL;
}

View File

@ -362,7 +362,7 @@ TORRENT_TEST(sanitize_path)
path.clear();
sanitize_append_path_element(path, "dev:", 4);
#ifdef TORRENT_WINDOWS
TEST_EQUAL(path, "dev");
TEST_EQUAL(path, "dev_");
#else
TEST_EQUAL(path, "dev:");
#endif
@ -371,7 +371,7 @@ TORRENT_TEST(sanitize_path)
sanitize_append_path_element(path, "c:", 2);
sanitize_append_path_element(path, "b", 1);
#ifdef TORRENT_WINDOWS
TEST_EQUAL(path, "c" SEPARATOR "b");
TEST_EQUAL(path, "c_" SEPARATOR "b");
#else
TEST_EQUAL(path, "c:" SEPARATOR "b");
#endif
@ -381,7 +381,7 @@ TORRENT_TEST(sanitize_path)
sanitize_append_path_element(path, ".", 1);
sanitize_append_path_element(path, "c", 1);
#ifdef TORRENT_WINDOWS
TEST_EQUAL(path, "c" SEPARATOR "c");
TEST_EQUAL(path, "c_" SEPARATOR "c");
#else
TEST_EQUAL(path, "c:" SEPARATOR "c");
#endif
@ -524,6 +524,17 @@ TORRENT_TEST(sanitize_path_zeroes)
TEST_EQUAL(path, "");
}
TORRENT_TEST(sanitize_path_colon)
{
std::string path;
sanitize_append_path_element(path, "foo:bar", 7);
#ifdef TORRENT_WINDOWS
TEST_EQUAL(path, "foo_bar");
#else
TEST_EQUAL(path, "foo:bar");
#endif
}
TORRENT_TEST(verify_encoding)
{
// verify_encoding
@ -643,7 +654,7 @@ TORRENT_TEST(parse_torrents)
torrent_info ti2(&buf[0], buf.size(), ec);
std::cerr << ti2.name() << std::endl;
#ifdef TORRENT_WINDOWS
TEST_EQUAL(ti2.name(), "ctest1test2test3");
TEST_EQUAL(ti2.name(), "c_test1test2test3");
#else
TEST_EQUAL(ti2.name(), "test1test2test3");
#endif