fix(Net): HTTPCookie Constructor Fails to Handle Discard Attribute Properly (#4664)

This commit is contained in:
Günter Obiltschnig 2024-09-26 11:25:44 +02:00
parent 42ccb0d96d
commit db1cc9507b
3 changed files with 19 additions and 1 deletions

View File

@ -119,7 +119,7 @@ HTTPCookie::HTTPCookie(const NameValueCollection& nvc):
{
setHttpOnly(true);
}
else
else if (_name.empty())
{
setName(name);
setValue(value);

View File

@ -192,6 +192,22 @@ void HTTPCookieTest::testCookieExpiry(DateTime expiryTime)
}
void HTTPCookieTest::testIgnoreExtraAttributes()
{
NameValueCollection nvc;
nvc.add("test", "foo");
nvc.add("Version", "1");
nvc.add("Path", "/test/path");
nvc.add("Discard", "");
nvc.add("HttpOnly", "");
HTTPCookie cookie(nvc);
assert (cookie.getName() == "test");
assert (cookie.getValue() == "foo");
assert (cookie.getHttpOnly());
}
void HTTPCookieTest::setUp()
{
}
@ -211,6 +227,7 @@ CppUnit::Test* HTTPCookieTest::suite()
CppUnit_addTest(pSuite, HTTPCookieTest, testUnescape);
CppUnit_addTest(pSuite, HTTPCookieTest, testExpiryFuture);
CppUnit_addTest(pSuite, HTTPCookieTest, testExpiryPast);
CppUnit_addTest(pSuite, HTTPCookieTest, testIgnoreExtraAttributes);
return pSuite;
}

View File

@ -31,6 +31,7 @@ public:
void testExpiryFuture();
void testExpiryPast();
void testCookieExpiry(Poco::DateTime expiryTime);
void testIgnoreExtraAttributes();
void setUp();
void tearDown();