mirror of
https://github.com/aria2/aria2.git
synced 2024-11-26 19:43:42 +08:00
2010-04-03 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that web-seed URI is not percent-encoded. * src/a2functional.h * src/bittorrent_helper.cc * test/BittorrentHelperTest.cc * test/url-list-multiFile.torrent * test/url-list-singleFileEndsWithSlash.torrent
This commit is contained in:
parent
919255b4db
commit
0e060f0e8b
@ -1,3 +1,12 @@
|
||||
2010-04-03 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Fixed the bug that web-seed URI is not percent-encoded.
|
||||
* src/a2functional.h
|
||||
* src/bittorrent_helper.cc
|
||||
* test/BittorrentHelperTest.cc
|
||||
* test/url-list-multiFile.torrent
|
||||
* test/url-list-singleFileEndsWithSlash.torrent
|
||||
|
||||
2010-04-02 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Added aria2.shutdown and aria2.forceShutdown XML-RPC method.
|
||||
|
@ -221,6 +221,25 @@ std::string strjoin(InputIterator first, InputIterator last,
|
||||
return result;
|
||||
}
|
||||
|
||||
// Applies unaryOp through first to last and joins the result with
|
||||
// delimiter delim.
|
||||
template<typename InputIterator, typename DelimiterType, typename UnaryOp>
|
||||
std::string strjoin(InputIterator first, InputIterator last,
|
||||
const DelimiterType& delim, const UnaryOp& unaryOp)
|
||||
{
|
||||
std::string result;
|
||||
if(first == last) {
|
||||
return result;
|
||||
}
|
||||
InputIterator beforeLast = last-1;
|
||||
for(; first != beforeLast; ++first) {
|
||||
result += unaryOp(*first);
|
||||
result += delim;
|
||||
}
|
||||
result += unaryOp(*beforeLast);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline std::string strconcat(const T1& a1, const T2& a2)
|
||||
{
|
||||
|
@ -254,8 +254,12 @@ static void extractFileEntries
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat(MSG_DIR_TRAVERSAL_DETECTED, path.c_str()).str());
|
||||
}
|
||||
std::string pePath =
|
||||
strjoin(pathelem.begin(), pathelem.end(), '/',
|
||||
std::ptr_fun(static_cast<std::string (*)(const std::string&)>
|
||||
(util::percentEncode)));
|
||||
std::vector<std::string> uris;
|
||||
createUri(urlList.begin(), urlList.end(), std::back_inserter(uris), path);
|
||||
createUri(urlList.begin(), urlList.end(),std::back_inserter(uris),pePath);
|
||||
SharedHandle<FileEntry> fileEntry
|
||||
(new FileEntry(util::applyDir(ctx->getDir(), util::escapePath(path)),
|
||||
fileLengthData.i(),
|
||||
@ -280,7 +284,7 @@ static void extractFileEntries
|
||||
for(std::vector<std::string>::const_iterator i = urlList.begin(),
|
||||
eoi = urlList.end(); i != eoi; ++i) {
|
||||
if(util::endsWith(*i, A2STR::SLASH_C)) {
|
||||
uris.push_back((*i)+name);
|
||||
uris.push_back((*i)+util::percentEncode(name));
|
||||
} else {
|
||||
uris.push_back(*i);
|
||||
}
|
||||
|
@ -351,24 +351,24 @@ void BittorrentHelperTest::testGetFileEntries_multiFileUrlList() {
|
||||
fileEntries.begin();
|
||||
|
||||
const SharedHandle<FileEntry>& fileEntry1 = *itr;
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("./aria2-test/aria2/src/aria2c"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("./aria2-test@/aria2@/src@/aria2c@"),
|
||||
fileEntry1->getPath());
|
||||
const std::deque<std::string>& uris1 = fileEntry1->getRemainingUris();
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, uris1.size());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/dist/aria2-test/aria2/src/aria2c"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/dist/aria2-test%40/aria2%40/src%40/aria2c%40"),
|
||||
uris1[0]);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://mirror/dist/aria2-test/aria2/src/aria2c"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://mirror/dist/aria2-test%40/aria2%40/src%40/aria2c%40"),
|
||||
uris1[1]);
|
||||
|
||||
++itr;
|
||||
const SharedHandle<FileEntry>& fileEntry2 = *itr;
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("./aria2-test/aria2-0.2.2.tar.bz2"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("./aria2-test@/aria2-0.2.2.tar.bz2"),
|
||||
fileEntry2->getPath());
|
||||
const std::deque<std::string>& uris2 = fileEntry2->getRemainingUris();
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, uris2.size());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/dist/aria2-test/aria2-0.2.2.tar.bz2"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/dist/aria2-test%40/aria2-0.2.2.tar.bz2"),
|
||||
uris2[0]);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://mirror/dist/aria2-test/aria2-0.2.2.tar.bz2"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://mirror/dist/aria2-test%40/aria2-0.2.2.tar.bz2"),
|
||||
uris2[1]);
|
||||
}
|
||||
|
||||
@ -400,11 +400,11 @@ void BittorrentHelperTest::testGetFileEntries_singleFileUrlListEndsWithSlash() {
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, fileEntries.size());
|
||||
|
||||
const SharedHandle<FileEntry>& fileEntry1 = fileEntries.front();
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("./aria2.tar.bz2"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("./aria2@.tar.bz2"),
|
||||
fileEntry1->getPath());
|
||||
const std::deque<std::string>& uris1 = fileEntry1->getRemainingUris();
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, uris1.size());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/dist/aria2.tar.bz2"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/dist/aria2%40.tar.bz2"),
|
||||
uris1[0]);
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
d8:url-listl22:http://localhost/dist/18:http://mirror/diste8:announce36:http://aria.rednoah.com/announce.php13:announce-listll15:http://tracker1el15:http://tracker2el15:http://tracker3ee7:comment17:REDNOAH.COM RULES13:creation datei1123456789e4:infod5:filesld6:lengthi284e4:pathl5:aria23:src6:aria2ceed6:lengthi100e4:pathl19:aria2-0.2.2.tar.bz2eee4:name10:aria2-test12:piece lengthi128e6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCee
|
||||
d8:url-listl22:http://localhost/dist/18:http://mirror/diste8:announce36:http://aria.rednoah.com/announce.php13:announce-listll15:http://tracker1el15:http://tracker2el15:http://tracker3ee7:comment17:REDNOAH.COM RULES13:creation datei1123456789e4:infod5:filesld6:lengthi284e4:pathl6:aria2@4:src@7:aria2c@eed6:lengthi100e4:pathl19:aria2-0.2.2.tar.bz2eee4:name11:aria2-test@12:piece lengthi128e6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCee
|
@ -1 +1 @@
|
||||
d8:url-list22:http://localhost/dist/8:announce36:http://aria.rednoah.com/announce.php13:announce-listll15:http://tracker1el15:http://tracker2el15:http://tracker3ee7:comment17:REDNOAH.COM RULES13:creation datei1123456789e4:infod6:lengthi380e4:name13:aria2.tar.bz212:piece lengthi128e6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCee
|
||||
d8:url-list22:http://localhost/dist/8:announce36:http://aria.rednoah.com/announce.php13:announce-listll15:http://tracker1el15:http://tracker2el15:http://tracker3ee7:comment17:REDNOAH.COM RULES13:creation datei1123456789e4:infod6:lengthi380e4:name14:aria2@.tar.bz212:piece lengthi128e6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCee
|
Loading…
Reference in New Issue
Block a user