summaryrefslogtreecommitdiff
path: root/src/DefaultBtAnnounce.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-05-23 22:16:04 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-05-23 22:16:04 +0900
commitc57259f8e719e34e7f3dbe2e73735b18aa46bc23 (patch)
tree96ac3ff86783e91cceaa0baf638320cc38f1bb23 /src/DefaultBtAnnounce.cc
parent0b906f40f1204e79cb43af3867468ab02a371075 (diff)
Use standard percent-encode for tracker request query
Diffstat (limited to 'src/DefaultBtAnnounce.cc')
-rw-r--r--src/DefaultBtAnnounce.cc39
1 files changed, 19 insertions, 20 deletions
diff --git a/src/DefaultBtAnnounce.cc b/src/DefaultBtAnnounce.cc
index 7aaf223c..44e4d545 100644
--- a/src/DefaultBtAnnounce.cc
+++ b/src/DefaultBtAnnounce.cc
@@ -161,25 +161,24 @@ std::string DefaultBtAnnounce::getAnnounceUrl()
const size_t keyLen = 8;
std::string uri = announceList_.getAnnounce();
uri += uriHasQuery(uri) ? "&" : "?";
- uri +=
- fmt("info_hash=%s&"
- "peer_id=%s&"
- "uploaded=%" PRId64 "&"
- "downloaded=%" PRId64 "&"
- "left=%" PRId64 "&"
- "compact=1&"
- "key=%s&"
- "numwant=%d&"
- "no_peer_id=1",
- util::torrentPercentEncode(bittorrent::getInfoHash(downloadContext_),
- INFO_HASH_LENGTH).c_str(),
- util::torrentPercentEncode(bittorrent::getStaticPeerId(),
- PEER_ID_LENGTH).c_str(),
- stat.getSessionUploadLength(), stat.getSessionDownloadLength(), left,
- util::torrentPercentEncode(bittorrent::getStaticPeerId() +
- PEER_ID_LENGTH - keyLen,
- keyLen).c_str(),
- numWant);
+ uri += fmt("info_hash=%s&"
+ "peer_id=%s&"
+ "uploaded=%" PRId64 "&"
+ "downloaded=%" PRId64 "&"
+ "left=%" PRId64 "&"
+ "compact=1&"
+ "key=%s&"
+ "numwant=%d&"
+ "no_peer_id=1",
+ util::percentEncode(bittorrent::getInfoHash(downloadContext_),
+ INFO_HASH_LENGTH).c_str(),
+ util::percentEncode(bittorrent::getStaticPeerId(), PEER_ID_LENGTH)
+ .c_str(),
+ stat.getSessionUploadLength(), stat.getSessionDownloadLength(),
+ left, util::percentEncode(bittorrent::getStaticPeerId() +
+ PEER_ID_LENGTH - keyLen,
+ keyLen).c_str(),
+ numWant);
if (tcpPort_) {
uri += fmt("&port=%u", tcpPort_);
}
@@ -190,7 +189,7 @@ std::string DefaultBtAnnounce::getAnnounceUrl()
}
if (!trackerId_.empty()) {
uri += "&trackerid=";
- uri += util::torrentPercentEncode(trackerId_);
+ uri += util::percentEncode(trackerId_);
}
if (option_->getAsBool(PREF_BT_FORCE_ENCRYPTION) ||
option_->getAsBool(PREF_BT_REQUIRE_CRYPTO)) {