mirror of https://github.com/aria2/aria2
Strip DQUOTE from cookie-value and updated doc.
parent
3026b18ecd
commit
286991e17d
|
@ -67,6 +67,8 @@ std::string::const_iterator getNextDigit
|
||||||
|
|
||||||
bool parseDate(time_t& time, const std::string& cookieDate)
|
bool parseDate(time_t& time, const std::string& cookieDate)
|
||||||
{
|
{
|
||||||
|
// Following algorithm is described in
|
||||||
|
// http://tools.ietf.org/html/rfc6265#section-5.1.1
|
||||||
std::vector<std::string> dateTokens;
|
std::vector<std::string> dateTokens;
|
||||||
for(std::string::const_iterator i = cookieDate.begin(),
|
for(std::string::const_iterator i = cookieDate.begin(),
|
||||||
eoi = cookieDate.end(); i != eoi;) {
|
eoi = cookieDate.end(); i != eoi;) {
|
||||||
|
@ -198,6 +200,8 @@ bool parse
|
||||||
const std::string& defaultPath,
|
const std::string& defaultPath,
|
||||||
time_t creationTime)
|
time_t creationTime)
|
||||||
{
|
{
|
||||||
|
// This implementation is based on the algorithm listed in
|
||||||
|
// http://tools.ietf.org/html/rfc6265
|
||||||
std::string::const_iterator nvEnd = cookieStr.begin();
|
std::string::const_iterator nvEnd = cookieStr.begin();
|
||||||
std::string::const_iterator end = cookieStr.end();
|
std::string::const_iterator end = cookieStr.end();
|
||||||
for(; nvEnd != end && *nvEnd != ';'; ++nvEnd);
|
for(; nvEnd != end && *nvEnd != ';'; ++nvEnd);
|
||||||
|
@ -211,6 +215,7 @@ bool parse
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string cookieValue = util::stripIter(eq+1, nvEnd);
|
std::string cookieValue = util::stripIter(eq+1, nvEnd);
|
||||||
|
cookieValue = util::strip(cookieValue, "\"");
|
||||||
time_t expiryTime = 0;
|
time_t expiryTime = 0;
|
||||||
bool foundExpires = false;
|
bool foundExpires = false;
|
||||||
bool persistent = false;
|
bool persistent = false;
|
||||||
|
|
|
@ -213,6 +213,13 @@ void CookieHelperTest::testParse()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), c.getDomain());
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), c.getDomain());
|
||||||
CPPUNIT_ASSERT(c.getHostOnly());
|
CPPUNIT_ASSERT(c.getHostOnly());
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
// DQUOTE around cookie-value
|
||||||
|
std::string str = "id=\"foo\";";
|
||||||
|
Cookie c;
|
||||||
|
CPPUNIT_ASSERT(cookie::parse(c, str, "localhost", "/", creationDate));
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("foo"), c.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CookieHelperTest::testReverseDomainLevel()
|
void CookieHelperTest::testReverseDomainLevel()
|
||||||
|
|
Loading…
Reference in New Issue