mirror of https://github.com/aria2/aria2
2010-01-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Handle redirected URI which is not properly percent encoded. * src/Request.cc * test/RequestTest.ccpull/1/head
parent
69850ada49
commit
60c16887e6
|
@ -1,3 +1,9 @@
|
|||
2010-01-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Handle redirected URI which is not properly percent encoded.
|
||||
* src/Request.cc
|
||||
* test/RequestTest.cc
|
||||
|
||||
2010-01-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Fixed the bug that causes segmentaiton fault when aria2 sees '404
|
||||
|
|
|
@ -127,19 +127,21 @@ bool Request::redirectUrl(const std::string& url) {
|
|||
_previousUrl = A2STR::NIL;
|
||||
_supportsPersistentConnection = true;
|
||||
++_redirectCount;
|
||||
std::string redirectedUrl;
|
||||
if(url.find("://") == std::string::npos) {
|
||||
// rfc2616 requires absolute URI should be provided by Location header
|
||||
// field, but some servers don't obey this rule.
|
||||
if(util::startsWith(url, "/")) {
|
||||
// abosulute path
|
||||
return parseUrl(strconcat(_protocol, "://", _host, url));
|
||||
redirectedUrl = strconcat(_protocol, "://", _host, url);
|
||||
} else {
|
||||
// relative path
|
||||
return parseUrl(strconcat(_protocol, "://", _host, _dir, "/", url));
|
||||
redirectedUrl = strconcat(_protocol, "://", _host, _dir, "/", url);
|
||||
}
|
||||
} else {
|
||||
return parseUrl(url);
|
||||
redirectedUrl = url;
|
||||
}
|
||||
return parseUrl(urlencode(redirectedUrl));
|
||||
}
|
||||
|
||||
bool Request::parseUrl(const std::string& url) {
|
||||
|
|
|
@ -362,6 +362,11 @@ void RequestTest::testRedirectUrl() {
|
|||
"relativepath/to/file"),
|
||||
req.getCurrentUrl());
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3, req.getRedirectCount());
|
||||
|
||||
// White space in path
|
||||
CPPUNIT_ASSERT(req.redirectUrl("http://example.org/white space"));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/white%20space"),
|
||||
req.getCurrentUrl());
|
||||
}
|
||||
|
||||
void RequestTest::testRedirectUrl2() {
|
||||
|
|
Loading…
Reference in New Issue