mirror of https://github.com/aria2/aria2
2008-10-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug that last character in URI is not encoded. * src/Request.cc * test/RequestTest.ccpull/1/head
parent
22af8b4b22
commit
1605b39a10
|
@ -1,3 +1,9 @@
|
||||||
|
2008-10-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Fixed the bug that last character in URI is not encoded.
|
||||||
|
* src/Request.cc
|
||||||
|
* test/RequestTest.cc
|
||||||
|
|
||||||
2008-10-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-10-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Fixed the bug that referer header field contains fragment.
|
Fixed the bug that referer header field contains fragment.
|
||||||
|
|
|
@ -96,10 +96,8 @@ static std::string urlencode(const std::string& src)
|
||||||
if(src.empty()) {
|
if(src.empty()) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
size_t lastIndex = src.size()-1;
|
|
||||||
result += " ";
|
result += " ";
|
||||||
size_t index = lastIndex;
|
for(int index = src.size()-1; index >= 0; --index) {
|
||||||
while(index-- > 0) {
|
|
||||||
const unsigned char c = result[index];
|
const unsigned char c = result[index];
|
||||||
// '/' is not urlencoded because src is expected to be a path.
|
// '/' is not urlencoded because src is expected to be a path.
|
||||||
if(Util::shouldUrlencode(c)) {
|
if(Util::shouldUrlencode(c)) {
|
||||||
|
|
|
@ -264,15 +264,15 @@ void RequestTest::testSetUrl16()
|
||||||
void RequestTest::testSetUrl17()
|
void RequestTest::testSetUrl17()
|
||||||
{
|
{
|
||||||
Request req;
|
Request req;
|
||||||
bool v = req.setUrl("http://host:80/file<with%2 %20space/file with space;param?a=/?");
|
bool v = req.setUrl("http://host:80/file<with%2 %20space/file with space;param%?a=/?");
|
||||||
CPPUNIT_ASSERT(v);
|
CPPUNIT_ASSERT(v);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("host"), req.getHost());
|
CPPUNIT_ASSERT_EQUAL(std::string("host"), req.getHost());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/file%3cwith%252%20%20space"), req.getDir());
|
CPPUNIT_ASSERT_EQUAL(std::string("/file%3cwith%252%20%20space"), req.getDir());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("file%20with%20space;param"), req.getFile());
|
CPPUNIT_ASSERT_EQUAL(std::string("file%20with%20space;param%25"), req.getFile());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("?a=/?"), req.getQuery());
|
CPPUNIT_ASSERT_EQUAL(std::string("?a=/?"), req.getQuery());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://host:80/file%3cwith%252%20%20space"
|
CPPUNIT_ASSERT_EQUAL(std::string("http://host:80/file%3cwith%252%20%20space"
|
||||||
"/file%20with%20space;param?a=/?"),
|
"/file%20with%20space;param%25?a=/?"),
|
||||||
req.getCurrentUrl());
|
req.getCurrentUrl());
|
||||||
CPPUNIT_ASSERT_EQUAL(req.getCurrentUrl(), req.getUrl());
|
CPPUNIT_ASSERT_EQUAL(req.getCurrentUrl(), req.getUrl());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue