support numeric suffixes to magnet link parameter names
This commit is contained in:
parent
42bf915437
commit
1b7884b220
|
@ -1,3 +1,4 @@
|
||||||
|
* support magnet link parameters with number siffixes
|
||||||
* consistently use "lt" namespace in examples and documentation
|
* consistently use "lt" namespace in examples and documentation
|
||||||
* fix Mingw build to use native cryptoAPI
|
* fix Mingw build to use native cryptoAPI
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,16 @@ namespace libtorrent {
|
||||||
string_view value;
|
string_view value;
|
||||||
std::tie(value, sv) = split_string(sv, '&');
|
std::tie(value, sv) = split_string(sv, '&');
|
||||||
|
|
||||||
|
// parameter names are allowed to have a .<number>-suffix.
|
||||||
|
// the number has no meaning, just strip it
|
||||||
|
// if the characters after the period are not digits, don't strip
|
||||||
|
// anything
|
||||||
|
string_view number;
|
||||||
|
string_view stripped_name;
|
||||||
|
std::tie(stripped_name, number) = split_string(name, '.');
|
||||||
|
if (std::all_of(number.begin(), number.end(), [](char const c) { return is_digit(c); } ))
|
||||||
|
name = stripped_name;
|
||||||
|
|
||||||
if (name == "dn"_sv) // display name
|
if (name == "dn"_sv) // display name
|
||||||
{
|
{
|
||||||
error_code e;
|
error_code e;
|
||||||
|
|
|
@ -538,3 +538,23 @@ TORRENT_TEST(parse_magnet_select_only_invalid_quotes)
|
||||||
test_select_only("magnet:?xt=urn:btih:cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
|
test_select_only("magnet:?xt=urn:btih:cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
|
||||||
"&dn=foo&so=\"1,2\"", {});
|
"&dn=foo&so=\"1,2\"", {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TORRENT_TEST(magnet_tr_x_uri)
|
||||||
|
{
|
||||||
|
add_torrent_params p = parse_magnet_uri("magnet:"
|
||||||
|
"?tr.0=udp://1"
|
||||||
|
"&tr.1=http://2"
|
||||||
|
"&tr=http://3"
|
||||||
|
"&xt=urn:btih:c352cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd");
|
||||||
|
TEST_CHECK((p.trackers == std::vector<std::string>{
|
||||||
|
"udp://1", "http://2", "http://3"}));
|
||||||
|
|
||||||
|
TEST_CHECK((p.tracker_tiers == std::vector<int>{0, 1, 2 }));
|
||||||
|
|
||||||
|
p = parse_magnet_uri("magnet:"
|
||||||
|
"?tr.a=udp://1"
|
||||||
|
"&tr.1=http://2"
|
||||||
|
"&xt=urn:btih:c352cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd");
|
||||||
|
TEST_CHECK((p.trackers == std::vector<std::string>{"http://2" }));
|
||||||
|
TEST_CHECK((p.tracker_tiers == std::vector<int>{0}));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue