mirror of https://github.com/aria2/aria2
2010-07-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that aria2 cannot handle %2F in FTP URI properly. If directory component starts with %2F which percent-encode of '/', client should issue CWD to absolute path, but aria2 does not do that. It just issues relative path and download fails. * src/FtpConnection.cc * test/FtpConnectionTest.ccpull/1/head
parent
880af94348
commit
52a6ea008e
|
@ -1,3 +1,12 @@
|
||||||
|
2010-07-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Fixed the bug that aria2 cannot handle %2F in FTP URI properly.
|
||||||
|
If directory component starts with %2F which percent-encode of
|
||||||
|
'/', client should issue CWD to absolute path, but aria2 does not
|
||||||
|
do that. It just issues relative path and download fails.
|
||||||
|
* src/FtpConnection.cc
|
||||||
|
* test/FtpConnectionTest.cc
|
||||||
|
|
||||||
2010-07-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-07-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Increased DOMAIN_EVICTION_TRIGGER to 2000
|
Increased DOMAIN_EVICTION_TRIGGER to 2000
|
||||||
|
|
|
@ -150,10 +150,14 @@ bool FtpConnection::sendCwd()
|
||||||
util::itos(cuid_).c_str(), baseWorkingDir_.c_str());
|
util::itos(cuid_).c_str(), baseWorkingDir_.c_str());
|
||||||
}
|
}
|
||||||
std::string request = "CWD ";
|
std::string request = "CWD ";
|
||||||
if(baseWorkingDir_ != "/") {
|
if(util::startsWith(util::toUpper(req_->getDir()), "/%2F")) {
|
||||||
request += baseWorkingDir_;
|
request += util::percentDecode(req_->getDir().substr(1));
|
||||||
|
} else {
|
||||||
|
if(baseWorkingDir_ != "/") {
|
||||||
|
request += baseWorkingDir_;
|
||||||
|
}
|
||||||
|
request += util::percentDecode(req_->getDir());
|
||||||
}
|
}
|
||||||
request += util::percentDecode(req_->getDir());
|
|
||||||
request += "\r\n";
|
request += "\r\n";
|
||||||
if(logger_->info()) {
|
if(logger_->info()) {
|
||||||
logger_->info(MSG_SENDING_REQUEST,
|
logger_->info(MSG_SENDING_REQUEST,
|
||||||
|
|
|
@ -30,6 +30,7 @@ class FtpConnectionTest:public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST(testReceivePwdResponse_badStatus);
|
CPPUNIT_TEST(testReceivePwdResponse_badStatus);
|
||||||
CPPUNIT_TEST(testSendCwd);
|
CPPUNIT_TEST(testSendCwd);
|
||||||
CPPUNIT_TEST(testSendCwd_baseWorkingDir);
|
CPPUNIT_TEST(testSendCwd_baseWorkingDir);
|
||||||
|
CPPUNIT_TEST(testSendCwd_absDir);
|
||||||
CPPUNIT_TEST(testSendSize);
|
CPPUNIT_TEST(testSendSize);
|
||||||
CPPUNIT_TEST(testReceiveSizeResponse);
|
CPPUNIT_TEST(testReceiveSizeResponse);
|
||||||
CPPUNIT_TEST(testSendRetr);
|
CPPUNIT_TEST(testSendRetr);
|
||||||
|
@ -41,6 +42,7 @@ private:
|
||||||
SharedHandle<FtpConnection> ftp_;
|
SharedHandle<FtpConnection> ftp_;
|
||||||
SharedHandle<Option> option_;
|
SharedHandle<Option> option_;
|
||||||
SharedHandle<AuthConfigFactory> authConfigFactory_;
|
SharedHandle<AuthConfigFactory> authConfigFactory_;
|
||||||
|
SharedHandle<Request> req_;
|
||||||
public:
|
public:
|
||||||
void setUp()
|
void setUp()
|
||||||
{
|
{
|
||||||
|
@ -55,8 +57,8 @@ public:
|
||||||
listenSocket->getAddrInfo(addrinfo);
|
listenSocket->getAddrInfo(addrinfo);
|
||||||
listenPort_ = addrinfo.second;
|
listenPort_ = addrinfo.second;
|
||||||
|
|
||||||
SharedHandle<Request> req(new Request());
|
req_.reset(new Request());
|
||||||
req->setUri("ftp://localhost/dir%20sp/hello%20world.img");
|
req_->setUri("ftp://localhost/dir%20sp/hello%20world.img");
|
||||||
|
|
||||||
clientSocket_.reset(new SocketCore());
|
clientSocket_.reset(new SocketCore());
|
||||||
clientSocket_->establishConnection("localhost", listenPort_);
|
clientSocket_->establishConnection("localhost", listenPort_);
|
||||||
|
@ -65,9 +67,9 @@ public:
|
||||||
clientSocket_->setBlockingMode();
|
clientSocket_->setBlockingMode();
|
||||||
|
|
||||||
serverSocket_.reset(listenSocket->acceptConnection());
|
serverSocket_.reset(listenSocket->acceptConnection());
|
||||||
ftp_.reset(new FtpConnection(1, clientSocket_, req,
|
ftp_.reset(new FtpConnection(1, clientSocket_, req_,
|
||||||
authConfigFactory_->createAuthConfig
|
authConfigFactory_->createAuthConfig
|
||||||
(req, option_.get()),
|
(req_, option_.get()),
|
||||||
option_.get()));
|
option_.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +85,7 @@ public:
|
||||||
void testReceivePwdResponse_badStatus();
|
void testReceivePwdResponse_badStatus();
|
||||||
void testSendCwd();
|
void testSendCwd();
|
||||||
void testSendCwd_baseWorkingDir();
|
void testSendCwd_baseWorkingDir();
|
||||||
|
void testSendCwd_absDir();
|
||||||
void testSendSize();
|
void testSendSize();
|
||||||
void testReceiveSizeResponse();
|
void testReceiveSizeResponse();
|
||||||
void testSendRetr();
|
void testSendRetr();
|
||||||
|
@ -282,6 +285,18 @@ void FtpConnectionTest::testSendCwd_baseWorkingDir()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("CWD /base/dir sp\r\n"), std::string(data));
|
CPPUNIT_ASSERT_EQUAL(std::string("CWD /base/dir sp\r\n"), std::string(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FtpConnectionTest::testSendCwd_absDir()
|
||||||
|
{
|
||||||
|
req_->setUri("http://localhost/%2fdir/file");
|
||||||
|
ftp_->setBaseWorkingDir("/base");
|
||||||
|
ftp_->sendCwd();
|
||||||
|
char data[32];
|
||||||
|
size_t len = sizeof(data);
|
||||||
|
serverSocket_->readData(data, len);
|
||||||
|
data[len] = '\0';
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("CWD /dir\r\n"), std::string(data));
|
||||||
|
}
|
||||||
|
|
||||||
void FtpConnectionTest::testSendSize()
|
void FtpConnectionTest::testSendSize()
|
||||||
{
|
{
|
||||||
ftp_->sendSize();
|
ftp_->sendSize();
|
||||||
|
|
Loading…
Reference in New Issue