Skip to content

Commit d8ea7fc

Browse files
committed
merged RC_1_1 into master
2 parents c6f0c9c + 1593916 commit d8ea7fc

File tree

5 files changed

+27
-17
lines changed

5 files changed

+27
-17
lines changed

ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
* resume data no longer has timestamps of files
7979
* require C++11 to build libtorrent
8080

81+
* restore path sanitization behavior of ":"
8182
* fix listen socket issue when disabling "force_proxy" mode
8283
* fix full allocation failure on APFS
8384

src/torrent_info.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,7 @@ namespace libtorrent {
9393
static const std::array<std::int32_t, 7> bad_cp = {{0x202a, 0x202b, 0x202c, 0x202d, 0x202e, 0x200e, 0x200f}};
9494
if (std::find(bad_cp.begin(), bad_cp.end(), c) != bad_cp.end()) return true;
9595

96-
#ifdef TORRENT_WINDOWS
97-
static const char invalid_chars[] = "/\\:";
98-
#else
9996
static const char invalid_chars[] = "/\\";
100-
#endif
10197
if (c > 127) return false;
10298
return std::strchr(invalid_chars, static_cast<char>(c)) != nullptr;
10399
}

test/main.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace {
7474
int old_stdout = -1;
7575
int old_stderr = -1;
7676
bool redirect_stdout = true;
77-
bool redirect_stderr = false;
77+
bool redirect_stderr = true;
7878
bool keep_files = false;
7979

8080
// the current tests file descriptor
@@ -83,15 +83,21 @@ unit_test_t* current_test = nullptr;
8383
void output_test_log_to_terminal()
8484
{
8585
if (current_test == nullptr
86-
|| (old_stdout == -1 && old_stderr == -1)
87-
|| (!redirect_stdout && !redirect_stderr)
8886
|| current_test->output == nullptr)
8987
return;
9088

9189
fflush(stdout);
9290
fflush(stderr);
93-
if (old_stdout != -1) dup2(old_stdout, fileno(stdout));
94-
if (old_stderr != -1) dup2(old_stderr, fileno(stderr));
91+
if (old_stdout != -1)
92+
{
93+
dup2(old_stdout, fileno(stdout));
94+
old_stdout = -1;
95+
}
96+
if (old_stderr != -1)
97+
{
98+
dup2(old_stderr, fileno(stderr));
99+
old_stderr = -1;
100+
}
95101

96102
fseek(current_test->output, 0, SEEK_SET);
97103
std::printf("\x1b[1m[%s]\x1b[0m\n\n", current_test->name);

test/test_torrent_info.cpp

+15-4
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ TORRENT_TEST(sanitize_path)
390390
path.clear();
391391
sanitize_append_path_element(path, "dev:");
392392
#ifdef TORRENT_WINDOWS
393-
TEST_EQUAL(path, "dev");
393+
TEST_EQUAL(path, "dev_");
394394
#else
395395
TEST_EQUAL(path, "dev:");
396396
#endif
@@ -399,7 +399,7 @@ TORRENT_TEST(sanitize_path)
399399
sanitize_append_path_element(path, "c:");
400400
sanitize_append_path_element(path, "b");
401401
#ifdef TORRENT_WINDOWS
402-
TEST_EQUAL(path, "c" SEPARATOR "b");
402+
TEST_EQUAL(path, "c_" SEPARATOR "b");
403403
#else
404404
TEST_EQUAL(path, "c:" SEPARATOR "b");
405405
#endif
@@ -409,7 +409,7 @@ TORRENT_TEST(sanitize_path)
409409
sanitize_append_path_element(path, ".");
410410
sanitize_append_path_element(path, "c");
411411
#ifdef TORRENT_WINDOWS
412-
TEST_EQUAL(path, "c" SEPARATOR "c");
412+
TEST_EQUAL(path, "c_" SEPARATOR "c");
413413
#else
414414
TEST_EQUAL(path, "c:" SEPARATOR "c");
415415
#endif
@@ -552,6 +552,17 @@ TORRENT_TEST(sanitize_path_zeroes)
552552
TEST_EQUAL(path, "_");
553553
}
554554

555+
TORRENT_TEST(sanitize_path_colon)
556+
{
557+
std::string path;
558+
sanitize_append_path_element(path, "foo:bar");
559+
#ifdef TORRENT_WINDOWS
560+
TEST_EQUAL(path, "foo_bar");
561+
#else
562+
TEST_EQUAL(path, "foo:bar");
563+
#endif
564+
}
565+
555566
TORRENT_TEST(verify_encoding)
556567
{
557568
// verify_encoding
@@ -669,7 +680,7 @@ TORRENT_TEST(parse_torrents)
669680
torrent_info ti2(buf, from_span);
670681
std::cout << ti2.name() << std::endl;
671682
#ifdef TORRENT_WINDOWS
672-
TEST_EQUAL(ti2.name(), "ctest1test2test3");
683+
TEST_EQUAL(ti2.name(), "c_test1test2test3");
673684
#else
674685
TEST_EQUAL(ti2.name(), "test1test2test3");
675686
#endif

test/test_tracker.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,6 @@ void test_udp_tracker(std::string const& iface, address tracker, tcp::endpoint c
370370
break;
371371

372372
std::this_thread::sleep_for(lt::milliseconds(100));
373-
std::printf("UDP: %d / %d\n", int(num_udp_announces())
374-
, int(prev_udp_announces) + 1);
375373
}
376374

377375
// we should have announced to the tracker by now
@@ -390,8 +388,6 @@ void test_udp_tracker(std::string const& iface, address tracker, tcp::endpoint c
390388
break;
391389

392390
std::this_thread::sleep_for(lt::milliseconds(100));
393-
std::printf("UDP: %d / %d\n", int(num_udp_announces())
394-
, int(prev_udp_announces) + 1);
395391
}
396392

397393
TEST_CHECK(peer_ep == expected_peer);

0 commit comments

Comments
 (0)