diff --git a/ChangeLog b/ChangeLog index bb59d3bb..3d2403d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2010-07-09 Tatsuhiro Tsujikawa + + 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 Increased DOMAIN_EVICTION_TRIGGER to 2000 diff --git a/src/FtpConnection.cc b/src/FtpConnection.cc index 2c454a32..0aaa9a4a 100644 --- a/src/FtpConnection.cc +++ b/src/FtpConnection.cc @@ -150,10 +150,14 @@ bool FtpConnection::sendCwd() util::itos(cuid_).c_str(), baseWorkingDir_.c_str()); } std::string request = "CWD "; - if(baseWorkingDir_ != "/") { - request += baseWorkingDir_; + if(util::startsWith(util::toUpper(req_->getDir()), "/%2F")) { + 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"; if(logger_->info()) { logger_->info(MSG_SENDING_REQUEST, diff --git a/test/FtpConnectionTest.cc b/test/FtpConnectionTest.cc index 6e5bae21..f175f091 100644 --- a/test/FtpConnectionTest.cc +++ b/test/FtpConnectionTest.cc @@ -30,6 +30,7 @@ class FtpConnectionTest:public CppUnit::TestFixture { CPPUNIT_TEST(testReceivePwdResponse_badStatus); CPPUNIT_TEST(testSendCwd); CPPUNIT_TEST(testSendCwd_baseWorkingDir); + CPPUNIT_TEST(testSendCwd_absDir); CPPUNIT_TEST(testSendSize); CPPUNIT_TEST(testReceiveSizeResponse); CPPUNIT_TEST(testSendRetr); @@ -41,6 +42,7 @@ private: SharedHandle ftp_; SharedHandle