forked from premiere/premiere-libtorrent
fixed magnet link parser to accept hex encoded info-hashes
This commit is contained in:
parent
76ce836fb9
commit
b75648445e
|
@ -33,6 +33,10 @@
|
|||
* added support for bitcomet padding files
|
||||
* improved support for sparse files on windows
|
||||
|
||||
release 0.14.4
|
||||
|
||||
* fixed magnet link parser to accept hex-encoded info-hashes
|
||||
|
||||
release 0.14.3
|
||||
|
||||
* added python binding for create_torrent
|
||||
|
|
|
@ -72,6 +72,13 @@ namespace libtorrent
|
|||
std::memcpy(m_number, &s[0], sl);
|
||||
}
|
||||
|
||||
void assign(std::string const& s)
|
||||
{
|
||||
TORRENT_ASSERT(s.size() >= 20);
|
||||
int sl = int(s.size()) < size ? int(s.size()) : size;
|
||||
std::memcpy(m_number, &s[0], sl);
|
||||
}
|
||||
|
||||
void assign(char const* str)
|
||||
{
|
||||
std::memcpy(m_number, str, size);
|
||||
|
|
|
@ -116,7 +116,9 @@ namespace libtorrent
|
|||
|
||||
if (btih->compare(0, 9, "urn:btih:") != 0) return torrent_handle();
|
||||
|
||||
sha1_hash info_hash(base32decode(btih->substr(9)));
|
||||
sha1_hash info_hash;
|
||||
if (btih->size() == 40 + 9) from_hex(&(*btih)[9], 40, (char*)&info_hash[0]);
|
||||
else info_hash.assign(base32decode(btih->substr(9)));
|
||||
|
||||
return ses.add_torrent(tracker.empty() ? 0 : tracker.c_str(), info_hash
|
||||
, name.empty() ? 0 : name.c_str(), save_path, entry()
|
||||
|
@ -158,7 +160,9 @@ namespace libtorrent
|
|||
return torrent_handle();
|
||||
}
|
||||
|
||||
sha1_hash info_hash(base32decode(btih->substr(9)));
|
||||
sha1_hash info_hash;
|
||||
if (btih->size() == 40 + 9) from_hex(&(*btih)[9], 40, (char*)&info_hash[0]);
|
||||
else info_hash.assign(base32decode(btih->substr(9)));
|
||||
|
||||
if (!tracker.empty()) p.tracker_url = tracker.c_str();
|
||||
p.info_hash = info_hash;
|
||||
|
|
Loading…
Reference in New Issue