Skip to content

Commit

Permalink
fix(Net): HTTPCookie Constructor Fails to Handle Discard Attribute Pr…
Browse files Browse the repository at this point in the history
…operly (#4664)
  • Loading branch information
obiltschnig committed Sep 26, 2024
1 parent 42ccb0d commit db1cc95
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Net/src/HTTPCookie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ HTTPCookie::HTTPCookie(const NameValueCollection& nvc):
{
setHttpOnly(true);
}
else
else if (_name.empty())
{
setName(name);
setValue(value);
Expand Down
17 changes: 17 additions & 0 deletions Net/testsuite/src/HTTPCookieTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
}
Expand All @@ -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;
}
1 change: 1 addition & 0 deletions Net/testsuite/src/HTTPCookieTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class HTTPCookieTest: public CppUnit::TestCase
void testExpiryFuture();
void testExpiryPast();
void testCookieExpiry(Poco::DateTime expiryTime);
void testIgnoreExtraAttributes();

void setUp();
void tearDown();
Expand Down

0 comments on commit db1cc95

Please sign in to comment.