forked from premiere/premiere-libtorrent
trim tracker urls and renamed isprint to is_print
This commit is contained in:
parent
fffda3c738
commit
ad1e575a6e
|
@ -45,7 +45,8 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
boost::array<char, 3 + std::numeric_limits<size_type>::digits10> TORRENT_EXPORT to_string(size_type n);
|
boost::array<char, 3 + std::numeric_limits<size_type>::digits10> TORRENT_EXPORT to_string(size_type n);
|
||||||
bool TORRENT_EXPORT is_digit(char c);
|
bool TORRENT_EXPORT is_digit(char c);
|
||||||
bool TORRENT_EXPORT isprint(char c);
|
bool TORRENT_EXPORT is_print(char c);
|
||||||
|
bool TORRENT_EXPORT is_space(char c);
|
||||||
char TORRENT_EXPORT to_lower(char c);
|
char TORRENT_EXPORT to_lower(char c);
|
||||||
|
|
||||||
bool TORRENT_EXPORT string_begins_no_case(char const* s1, char const* s2);
|
bool TORRENT_EXPORT string_begins_no_case(char const* s1, char const* s2);
|
||||||
|
|
|
@ -152,6 +152,12 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
return fails == 0;
|
return fails == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void trim()
|
||||||
|
{
|
||||||
|
while (!url.empty() && is_space(url[0]))
|
||||||
|
url.erase(url.begin());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
|
|
|
@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/extensions.hpp"
|
#include "libtorrent/extensions.hpp"
|
||||||
#include "libtorrent/aux_/session_impl.hpp"
|
#include "libtorrent/aux_/session_impl.hpp"
|
||||||
#include "libtorrent/broadcast_socket.hpp"
|
#include "libtorrent/broadcast_socket.hpp"
|
||||||
|
#include "libtorrent/escape_string.hpp"
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||||
#include "libtorrent/pe_crypto.hpp"
|
#include "libtorrent/pe_crypto.hpp"
|
||||||
|
@ -2728,7 +2729,7 @@ namespace libtorrent
|
||||||
char ascii_pid[21];
|
char ascii_pid[21];
|
||||||
for (int i = 0; i != 20; ++i)
|
for (int i = 0; i != 20; ++i)
|
||||||
{
|
{
|
||||||
if (isprint(recv_buffer.begin[i])) ascii_pid[i] = recv_buffer.begin[i];
|
if (is_print(recv_buffer.begin[i])) ascii_pid[i] = recv_buffer.begin[i];
|
||||||
else ascii_pid[i] = '.';
|
else ascii_pid[i] = '.';
|
||||||
}
|
}
|
||||||
char msg[200];
|
char msg[200];
|
||||||
|
|
|
@ -43,10 +43,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/escape_string.hpp"
|
#include "libtorrent/escape_string.hpp"
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
using ::isprint;
|
|
||||||
}
|
|
||||||
#define for if (false) {} else for
|
#define for if (false) {} else for
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -370,7 +366,7 @@ namespace libtorrent
|
||||||
bool binary_string = false;
|
bool binary_string = false;
|
||||||
for (std::string::const_iterator i = string().begin(); i != string().end(); ++i)
|
for (std::string::const_iterator i = string().begin(); i != string().end(); ++i)
|
||||||
{
|
{
|
||||||
if (!std::isprint(static_cast<unsigned char>(*i)))
|
if (!is_print(static_cast<unsigned char>(*i)))
|
||||||
{
|
{
|
||||||
binary_string = true;
|
binary_string = true;
|
||||||
break;
|
break;
|
||||||
|
@ -395,7 +391,7 @@ namespace libtorrent
|
||||||
bool binary_string = false;
|
bool binary_string = false;
|
||||||
for (std::string::const_iterator k = i->first.begin(); k != i->first.end(); ++k)
|
for (std::string::const_iterator k = i->first.begin(); k != i->first.end(); ++k)
|
||||||
{
|
{
|
||||||
if (!std::isprint(static_cast<unsigned char>(*k)))
|
if (!is_print(static_cast<unsigned char>(*k)))
|
||||||
{
|
{
|
||||||
binary_string = true;
|
binary_string = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -87,11 +87,16 @@ namespace libtorrent
|
||||||
return c >= '0' && c <= '9';
|
return c >= '0' && c <= '9';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isprint(char c)
|
bool is_print(char c)
|
||||||
{
|
{
|
||||||
return c >= 32 && c < 127;
|
return c >= 32 && c < 127;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_space(char c)
|
||||||
|
{
|
||||||
|
return c == ' ' || c == '\t';
|
||||||
|
}
|
||||||
|
|
||||||
char to_lower(char c)
|
char to_lower(char c)
|
||||||
{
|
{
|
||||||
return (c >= 'A' && c <= 'Z') ? c - 'A' + 'a' : c;
|
return (c >= 'A' && c <= 'Z') ? c - 'A' + 'a' : c;
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace
|
||||||
{
|
{
|
||||||
fingerprint ret("..", 0, 0, 0, 0);
|
fingerprint ret("..", 0, 0, 0, 0);
|
||||||
|
|
||||||
if (id[0] != '-' || !isprint(id[1]) || (id[2] < '0')
|
if (id[0] != '-' || !is_print(id[1]) || (id[2] < '0')
|
||||||
|| (id[3] < '0') || (id[4] < '0')
|
|| (id[3] < '0') || (id[4] < '0')
|
||||||
|| (id[5] < '0') || (id[6] < '0')
|
|| (id[5] < '0') || (id[6] < '0')
|
||||||
|| id[7] != '-')
|
|| id[7] != '-')
|
||||||
|
@ -131,7 +131,7 @@ namespace
|
||||||
ret.tag_version = 0;
|
ret.tag_version = 0;
|
||||||
if (sscanf(ids, "%c%d-%d-%d--", &ret.name[0], &ret.major_version, &ret.minor_version
|
if (sscanf(ids, "%c%d-%d-%d--", &ret.name[0], &ret.major_version, &ret.minor_version
|
||||||
, &ret.revision_version) != 4
|
, &ret.revision_version) != 4
|
||||||
|| !isprint(ret.name[0]))
|
|| !is_print(ret.name[0]))
|
||||||
return boost::optional<fingerprint>();
|
return boost::optional<fingerprint>();
|
||||||
|
|
||||||
return boost::optional<fingerprint>(ret);
|
return boost::optional<fingerprint>(ret);
|
||||||
|
@ -384,7 +384,7 @@ namespace libtorrent
|
||||||
std::string unknown("Unknown [");
|
std::string unknown("Unknown [");
|
||||||
for (peer_id::const_iterator i = p.begin(); i != p.end(); ++i)
|
for (peer_id::const_iterator i = p.begin(); i != p.end(); ++i)
|
||||||
{
|
{
|
||||||
unknown += isprint(char(*i))?*i:'.';
|
unknown += is_print(char(*i))?*i:'.';
|
||||||
}
|
}
|
||||||
unknown += "]";
|
unknown += "]";
|
||||||
return unknown;
|
return unknown;
|
||||||
|
|
|
@ -391,7 +391,7 @@ namespace libtorrent
|
||||||
for (int i = 0; i < e.string_length(); ++i)
|
for (int i = 0; i < e.string_length(); ++i)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
if (isprint((unsigned char)str[i])) continue;
|
if (is_print((unsigned char)str[i])) continue;
|
||||||
printable = false;
|
printable = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -776,6 +776,7 @@ namespace libtorrent
|
||||||
e.tier = j;
|
e.tier = j;
|
||||||
e.fail_limit = 0;
|
e.fail_limit = 0;
|
||||||
e.source = announce_entry::source_torrent;
|
e.source = announce_entry::source_torrent;
|
||||||
|
e.trim();
|
||||||
m_urls.push_back(e);
|
m_urls.push_back(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -805,6 +806,7 @@ namespace libtorrent
|
||||||
announce_entry e(torrent_file.dict_find_string_value("announce"));
|
announce_entry e(torrent_file.dict_find_string_value("announce"));
|
||||||
e.fail_limit = 0;
|
e.fail_limit = 0;
|
||||||
e.source = announce_entry::source_torrent;
|
e.source = announce_entry::source_torrent;
|
||||||
|
e.trim();
|
||||||
if (!e.url.empty()) m_urls.push_back(e);
|
if (!e.url.empty()) m_urls.push_back(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue